function DrupalBoot::bootstrap_drupal_root

8.0.x DrupalBoot.php DrupalBoot::bootstrap_drupal_root()
7.x DrupalBoot.php DrupalBoot::bootstrap_drupal_root()
master DrupalBoot.php DrupalBoot::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 Drupal site. We can now include files from the Drupal Tree, and figure out more context about the platform, such as the version of Drupal.

File

lib/Drush/Boot/DrupalBoot.php, line 308

Namespace

Drush\Boot

Class

DrupalBoot

Code

function bootstrap_drupal_root() {
  // Load the config options from Drupal's /drush and sites/all/drush directories.
  drush_load_config('drupal');

  $drupal_root = drush_set_context('DRUSH_DRUPAL_ROOT', drush_bootstrap_value('drupal_root'));
  chdir($drupal_root);
  $version = drush_drupal_version();
  $major_version = drush_drupal_major_version();

  $core = $this->bootstrap_drupal_core($drupal_root);

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

  _drush_preflight_global_options();

  $this->logger->log(LogLevel::BOOTSTRAP, dt("Initialized Drupal !version root directory at !drupal_root", array("!version" => $version, '!drupal_root' => $drupal_root)));
}