function DrupalBoot8::bootstrap_drupal_configuration

8.0.x DrupalBoot8.php DrupalBoot8::bootstrap_drupal_configuration()
7.x DrupalBoot8.php DrupalBoot8::bootstrap_drupal_configuration()
master DrupalBoot8.php DrupalBoot8::bootstrap_drupal_configuration()

Initialize and load the Drupal configuration files.

We process and store a normalized set of database credentials from the loaded configuration file, so we can validate them and access them easily in the future.

Also override Drupal variables as per --variables option.

Overrides DrupalBoot::bootstrap_drupal_configuration

File

lib/Drush/Boot/DrupalBoot8.php, line 120

Namespace

Drush\Boot

Class

DrupalBoot8

Code

function bootstrap_drupal_configuration() {
  $this->request = Request::createFromGlobals();
  $classloader = drush_drupal_load_autoloader(DRUPAL_ROOT);
  // @todo - use Request::create() and then no need to set PHP superglobals
  $kernelClass = new \ReflectionClass('\Drupal\Core\DrupalKernel');
  if ($kernelClass->hasMethod('addServiceModifier')) {
    $this->kernel = DrupalKernel::createFromRequest($this->request, $classloader, 'prod', DRUPAL_ROOT);
  }
  else {
    $this->kernel = DrushDrupalKernel::createFromRequest($this->request, $classloader, 'prod', DRUPAL_ROOT);
  }
  // @see Drush\Drupal\DrupalKernel::addServiceModifier()
  $this->kernel->addServiceModifier(new DrushServiceModfier());

  // Unset drupal error handler and restore Drush's one.
  restore_error_handler();

  // Disable automated cron if the module is enabled.
  $GLOBALS['config']['automated_cron.settings']['interval'] = 0;

  parent::bootstrap_drupal_configuration();
}