function d

7.x-3.x &d($name = NULL, $_root_object = FALSE, $allow_creation = TRUE)

Store and access context objects by alias name.


$name: A Drush alias name, including leading @.

$_root_object: Internal use only, set default object returned by d().

$allow_creation: Defaults to TRUE. Allows creating a new context object with the specified $name.

Return value

provision_Context object (by reference) or NULL if it can't be loaded and $allow_creation == FALSE.

121 calls to d()
db_drush_exit in db/
Implements hook_drush_exit(). in platform/drupal/
Handle site migration tasks for redeployed sites. This is primarily to handle the rename of the sites directories.
drush_db_post_provision_deploy in db/
drush_db_post_provision_migrate in db/
drush_db_post_provision_restore in db/

... See full list

2 string references to 'd'


./, line 23
Provision named context base classes and the function d().


function &d($name = NULL, $_root_object = FALSE, $allow_creation = TRUE) {
  static $instances = null;
  static $default_instance = '@self';

   * add safety check so that we don't get caught running d() before drush is
   * fully initialized. otherwise, the proper services hooks may not be
   * properly declared and found by drush, so the object cache ($instances)
   * would be initialised with incomplete data.
   * it is possible that more initialisation we need happens after
   * DRUSH_BOOTSTRAP_NONE, but this is already better than nothing.
   * if something is weird with d(), it may be that it is being called too
   * early and that check is failing to detect that, so watch out, it took two
   * senior Aegir developpers three full days of headbanging on keyboards to
   * figure that stuff out.
  if (drush_get_context('DRUSH_BOOTSTRAP_PHASE') == DRUSH_BOOTSTRAP_NONE) {
    $ret = drush_set_error('DRUSH_BOOTSTRAPPING', 'drush is still bootstrapping, d() should be ran only within a hook or a function');
    return $ret;

  if (is_object($name)) {
    return $name;

  if ($name == 'all') {
    return $instances;

  if (is_null($name)) {
    $name = $default_instance;

  if ($_root_object) {
    $default_instance = $name;

  $name = provision_normalise_context_name($name);

  if (isset($instances[$name])) {
    return $instances[$name];
  else {
    $instances[$name] = provision_context_factory($name, $allow_creation);
    if (!is_null($instances[$name])) {
    return $instances[$name];