Skip to content

Instantly share code, notes, and snippets.

View joshirohit100's full-sized avatar
🏠
Working Remotely

Rohit Joshi joshirohit100

🏠
Working Remotely
View GitHub Profile
drush -l [URL HERE] ev '$uid=UIDHERE; $user=\Drupal\user\Entity\User::load($uid);$user->set("field_password_expiration", 0);$user->save();'
$servername = 'localhost';
$username = 'drupal';
$password = 'drupal';
$database = 'drupal';
$table_name = 'employees';
try {
$conn = new \PDO("mysql:host=$servername;dbname=$database", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@joshirohit100
joshirohit100 / cache-context-block.php
Created March 10, 2017 10:24
Custom cache context sample
<?php
namespace Drupal\rohit\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Cache\Cache;
use Drupal\user\Entity\User;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a block to display 'Site branding' elements.
*
* @Block(