Skip to content

Instantly share code, notes, and snippets.

View vishwac09's full-sized avatar
🐇
Unsteady - pacing

Vishwa Chikate vishwac09

🐇
Unsteady - pacing
  • Srijan Technologies Ltd
  • Pune, India
  • X @vishwac09
View GitHub Profile
@vishwac09
vishwac09 / docker-compose.yml
Created October 9, 2024 05:57
SonarQube Community - Free edition
#
# Based on https://hub.docker.com/_/sonarqube
#
version: "3.7"
services:
sonarqube:
container_name: sonarqube
image: arm64v8/sonarqube:latest
@vishwac09
vishwac09 / methodAPI.php
Created September 22, 2022 18:15
EntityConvert methods API
<?php
use DrupalUtils\EntityConvert\EntityConvert;
$entityConvert = new EntityConvert();
// $instance == Node/User/Taxonomy/File.
$entityConvert->toArray($instance, true);
$entityConvert->toObject($instance, false);
// The toArray method accepts 2 arguments.
@vishwac09
vishwac09 / EntityConvert.php
Created September 22, 2022 17:59
Using the Entity Convert Library
<?php
use Drupal\node\Entity\Node;
// Include the library.
use DrupalUtils\EntityConvert\EntityConvert;
// Load instance of node
$node = Node::load(1);
@vishwac09
vishwac09 / toArray.php
Last active September 22, 2022 17:57
EntityConvert getting response as an array
<?php
use Drupal\Node\Entity\Node;
use DrupalUtils\EntityConvert\EntityConvert;
// Load instance of node
$node = Node::load(1);
// Creating a new Instance.
$entityConvert = new EntityConvert();
@vishwac09
vishwac09 / toObject.php
Last active September 22, 2022 17:58
EntityConvert getting response as an object
<?php
use Drupal\Node\Entity\Node;
use DrupalUtils\EntityConvert\EntityConvert;
// Load instance of node
$node = Node::load(1);
// Creating a new Instance.
$entityConvert = new EntityConvert();
@vishwac09
vishwac09 / RestAuth.php
Last active June 25, 2022 10:59
Drupal8 AuthenticationProvider Example
<?php
namespace Drupal\rest_auth\Authentication;
use Drupal\Core\Authentication\AuthenticationProviderInterface;
use Symfony\Component\HttpFoundation\Request;
use Drupal\Core\Session\UserSession;
use Symfony\Component\HttpKernel\Exception\HttpException;
/**
@vishwac09
vishwac09 / ChangeBaseFieldType.php
Created May 7, 2022 16:25
ChangeBaseFieldType
<?php
function vehicle_update_8001() {
$database = \Drupal::database();
$transaction = $database->startTransaction();
$entity_type_manager = \Drupal::entityTypeManager();
// The entity whose field type needs to be updated.
$bundle_of = 'vehicle';
@vishwac09
vishwac09 / Invitation.php
Created March 22, 2022 11:10
PHP Pseudo code showing resource handler implementation for PATCH requests.
<?php
class Invitation {
/**
* Callback handler for HTTP Patch request.
* @param int|null $id
* @param Request|null $request
*/
public function patch(int $id = NULL, Request $request = NULL) {
@vishwac09
vishwac09 / AuthZeroServiceTest.php
Created March 18, 2022 16:48
AuthZeroServiceTest UnitTest Case implementation
<?php
namespace Drupal\Tests\authzero\Unit;
use Drupal\authzero\Service\AuthZeroService;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Config\ImmutableConfig;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\HttpFoundation\Request;
@vishwac09
vishwac09 / AuthZeroService.php
Created March 18, 2022 11:50
AuthZeroService snippet for writing Unit Test cases
<?php
namespace Drupal\authzero\Service;
use Drupal\Core\Config\ConfigFactoryInterface;
/**
* Set of utility functions.
*/
class AuthZeroService {