_drush_bootstrap_drupal_root

  1. drupal
    1. 7 bootstrap.inc function
Drupal 7 _drush_bootstrap_drupal_root()

Bootstrap Drush with a valid Drupal Directory.

In this function, the pwd will be moved to the root of the Drupal installation.

The DRUSH_DRUPAL_ROOT context, DRUSH_DRUPAL_CORE context, DRUPAL_ROOT, and the DRUSH_DRUPAL_CORE constants are populated from the value that we determined during the validation phase.

We also now load the drushrc.php for this specific platform. We can now include files from the Drupal Tree, and figure out more context about the platform, such as the version of Drupal.

1 string reference to '_drush_bootstrap_drupal_root'

File

sites/all/modules/drush/includes/bootstrap.inc, line 679
Drush bootstrapping code.

Code

function _drush_bootstrap_drupal_root() {
  $drupal_root = drush_set_context('DRUSH_DRUPAL_ROOT', drush_bootstrap_value('drupal_root'));
  define('DRUPAL_ROOT', $drupal_root);

  chdir($drupal_root);
  require_once DRUPAL_ROOT . '/' . DRUSH_DRUPAL_SIGNATURE;
  $version = drush_set_context('DRUSH_DRUPAL_VERSION', drush_drupal_version());
  $major_version = drush_set_context('DRUSH_DRUPAL_MAJOR_VERSION', drush_drupal_major_version());

  // DRUSH_DRUPAL_CORE should point to the /core folder in Drupal 8+ or to DRUPAL_ROOT
  // in prior versions.
  $core = $major_version >= 8 ? DRUPAL_ROOT . '/core' : DRUPAL_ROOT;
  drush_set_context('DRUSH_DRUPAL_CORE', $core);
  define('DRUSH_DRUPAL_CORE', $core);

  _drush_bootstrap_global_options();

  drush_log(dt("Initialized Drupal !version root directory at !drupal_root", array("!version" => $version, '!drupal_root' => $drupal_root)));
}