Skip to content

Instantly share code, notes, and snippets.

@damiankloip
Created September 5, 2015 14:29
Show Gist options
  • Save damiankloip/b0c866b66072b3bfc956 to your computer and use it in GitHub Desktop.
Save damiankloip/b0c866b66072b3bfc956 to your computer and use it in GitHub Desktop.
Drush PsySH config
<?php
$config = [];
# If the shell has been booted by drush check for a version file.
if (function_exists('drush_drupal_major_version')) {
$drupal_version = drush_drupal_major_version();
$include_path = __DIR__ . '/includes';
$drupal_version_include = "$include_path/drupal-$drupal_version.php";
if ($drupal_version && file_exists($drupal_version_include)) {
$config['defaultIncludes'][] = $drupal_version_include;
}
}
return $config;
<?php
echo sprintf("Drupal version: %s\n", \Drupal::VERSION);
$em = \Drupal::entityManager();
$config_factory = \Drupal::configFactory();
$http_client = \Drupal::httpClient();
$module_handler = \Drupal::moduleHandler();
$token = \Drupal::token();
$csrf = \Drupal::csrfToken();
$url_generator = \Drupal::urlGenerator();
$link_generator = \Drupal::linkGenerator();
// Create an alias with no namespace for each entity type.
// E.g. 'Drupal\node\Entity\Node' gets an alias of 'Node'.
foreach ($em->getDefinitions() as $entity_type) {
$class = $entity_type->getClass();
class_alias($class, (new \ReflectionClass($class))->getShortName());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment