Notes

Git set credential helper
git config credential.helper store

 

Drupal 8: Re-run cron while it is already running
# Execute `php-eval` drush's command to release cron's flag
drush php-eval "\Drupal::lock()->release('cron');"

 

Load all taxonomy vocabularies
\Drupal\taxonomy\Entity\Vocabulary::loadMultiple()

 

Load taxonomy tree based on vocabulary
\Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree($vid);

 

Pantheon - Drupal 8 + Upstream Updates
# Official Pantheon documentation reference here: https://pantheon.io/docs/core-updates/#overwrite-core
 git pull -Xtheirs git://github.com/pantheon-systems/drops-8.git master

 

Drupal 8 Load EntityViewDisplay instance

use Drupal\Core\Entity\Entity\EntityViewDisplay;

// Define values to load entity
$entity_type = 'node';
$bundle = 'article';
$view_mode = 'teaser';

// Setup entity view display ID
$entity_id = sprintf('%s.%s.%s', $entity_type, $bundle, $view_mode);

// Load entity view display object using entity id.
$entityViewDisplay = EntityViewDisplay::load($entity_id);

 

Drupal 8 countQuery()
$result = \Drupal::database()->select('node')
  ->condition('type', 'article')
  ->countQuery()
  ->execute()->fetchField();

 

Drupal 8 Delete all content by code
// Define entity type to lookup.
$entity_type = 'node';

// Execute a query in order to retrieve an array of Article's ids.
$ids = \Drupal::entityQuery($entity_type)
  ->condition('type', 'article')
  ->execute();

/** @var \Drupal\node\NodeStorage $controller */
$controller = \Drupal::entityTypeManager()
  ->getStorage($entity_type);

/** @var \Drupal\node\Entity\Node[] $entities */
$entities = $controller->loadMultiple($ids);

// Deletes permanently saved entities.
$controller->delete($entities);

 

Git Add New Remote
git remote add  [REMOTE_NAME] [REPOSITORY_URL]
git push -u github master

 

Git reset changes
git reset --hard