class DrupalBoot8

  1. 8.0.x lib/Drush/Boot/DrupalBoot8.php DrupalBoot8
  2. 7.x lib/Drush/Boot/DrupalBoot8.php DrupalBoot8
  3. master lib/Drush/Boot/DrupalBoot8.php DrupalBoot8

Namespace

Drush\Boot

Hierarchy

Expanded class hierarchy of DrupalBoot8

Members

Contains filters are case sensitive
Namesort descending Modifiers Type Description
BaseBoot::bootstrap_and_dispatch function Main entrypoint to bootstrap the selected CMS and execute the selected command. Overrides Boot::bootstrap_and_dispatch
DrupalBoot8::$kernel protected property
DrupalBoot8::$request protected property
DrupalBoot8::add_logger function
DrupalBoot8::bootstrap_drupal_configuration function Initialize and load the Drupal configuration files. Overrides DrupalBoot::bootstrap_drupal_configuration
DrupalBoot8::bootstrap_drupal_core function
DrupalBoot8::bootstrap_drupal_database function Boostrap the Drupal database. Overrides DrupalBoot::bootstrap_drupal_database
DrupalBoot8::bootstrap_drupal_database_validate function Validate the DRUSH_BOOTSTRAP_DRUPAL_DATABASE phase Overrides DrupalBoot::bootstrap_drupal_database_validate
DrupalBoot8::bootstrap_drupal_full function Attempt to load the full Drupal system. Overrides DrupalBoot::bootstrap_drupal_full
DrupalBoot8::conf_path function Overrides DrupalBoot::conf_path
DrupalBoot8::contrib_modules_paths function Overrides DrupalBoot::contrib_modules_paths
DrupalBoot8::contrib_themes_paths function Overrides DrupalBoot::contrib_themes_paths
DrupalBoot8::get_profile function Overrides DrupalBoot::get_profile
DrupalBoot8::get_version function Given a site root directory, determine the exact version of the software. Overrides DrupalBoot::get_version
DrupalBoot8::terminate public function This method is called during the shutdown of drush. Overrides BaseBoot::terminate
DrupalBoot8::valid_root function This function determines if the specified path points to the root directory of a CMS that can be bootstrapped by the specific subclass that implements it. Overrides DrupalBoot::valid_root
DrupalBoot::bootstrap_do_drupal_site function Called by bootstrap_drupal_site to do the main work of the drush drupal site bootstrap.
DrupalBoot::bootstrap_drupal_database_has_table function Test to see if the Drupal database has a specified table or tables.
DrupalBoot::bootstrap_drupal_login function Log into the bootstrapped Drupal site with a specific username or user id.
DrupalBoot::bootstrap_drupal_root function Bootstrap Drush with a valid Drupal Directory.
DrupalBoot::bootstrap_drupal_root_validate function Validate the DRUSH_BOOTSTRAP_DRUPAL_ROOT phase.
DrupalBoot::bootstrap_drupal_site function Initialize a site on the Drupal root.
DrupalBoot::bootstrap_drupal_site_setup_server_global function Set up the $_SERVER globals so that Drupal will see the same values that it does when serving pages via the web server.
DrupalBoot::bootstrap_drupal_site_validate function VALIDATE the DRUSH_BOOTSTRAP_DRUPAL_SITE phase.
DrupalBoot::bootstrap_drupal_site_validate_settings_present function Validate that the Drupal site has all of the settings that it needs to operated.
DrupalBoot::bootstrap_init_phases function List of bootstrap phases where Drush should stop and look for commandfiles. Overrides Boot::bootstrap_init_phases
DrupalBoot::bootstrap_phases function Bootstrap phases used with Drupal: Overrides Boot::bootstrap_phases
DrupalBoot::commandfile_searchpaths function
DrupalBoot::command_defaults function Return an array of default values that should be added to every command (e.g. values needed in enforce_requirements(), etc.) Overrides BaseBoot::command_defaults
DrupalBoot::drush_command_belongs_to_disabled_module function Check if the given command belongs to a disabled module.
DrupalBoot::drush_enforce_requirement_drupal_dependencies function Check that a command has its declared dependencies available or have no dependencies.
DrupalBoot::enforce_requirement function Called by Drush when a command is selected, but before it runs. This gives the Boot class an opportunity to determine if any minimum requirements (e.g. minimum Drupal version) declared in the command have been met. Overrides BaseBoot::enforce_requirement
DrupalBoot::report_command_error function Called by Drush if a command is not found, or if the command was found, but did not meet requirements. Overrides BaseBoot::report_command_error
DrupalBoot::__construct function Overrides BaseBoot::__construct

File

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

View source
class DrupalBoot8 extends DrupalBoot {

  /**
   * @var \Drupal\Core\DrupalKernelInterface
   */
  protected $kernel;

  /**
   * @var \Symfony\Component\HttpFoundation\Request
   */
  protected $request;

  function valid_root($path) {
    if (!empty($path) && is_dir($path) && file_exists($path . '/index.php')) {
      // Additional check for the presence of core/composer.json to
      // grant it is not a Drupal 7 site with a base folder named "core".
      $candidate = 'core/includes/common.inc';
      if (file_exists($path . '/' . $candidate) && file_exists($path . '/core/core.services.yml')) {
        if (file_exists($path . '/core/misc/drupal.js') || file_exists($path . '/core/assets/js/drupal.js')) {
          return $candidate;
        }
      }
    }
  }

  function get_version($drupal_root) {
    // Load the autoloader so we can access the class constants.
    drush_drupal_load_autoloader($drupal_root);
    // Drush depends on bootstrap being loaded at this point.
    require_once $drupal_root . '/core/includes/bootstrap.inc';
    if (defined('Drupal::VERSION')) {
      return \Drupal::VERSION;
    }
  }

  function get_profile() {
    return drupal_get_profile();
  }

  function conf_path($require_settings = TRUE, $reset = FALSE, Request $request = NULL) {
    if (!isset($request)) {
      if (\Drupal::hasRequest()) {
        $request = \Drupal::request();
      }
      // @todo Remove once external CLI scripts (Drush) are updated.
      else {
        $request = Request::createFromGlobals();
      }
    }
    if (\Drupal::hasService('kernel')) {
      $site_path = \Drupal::service('kernel')->getSitePath();
    }
    if (!isset($site_path) || empty($site_path)) {
      $site_path = DrupalKernel::findSitePath($request, $require_settings);
    }
    return $site_path;
  }

  function add_logger() {
    // If we're running on Drupal 8 or later, we provide a logger which will send
    // output to drush_log(). This should catch every message logged through every
    // channel.
    $container = \Drupal::getContainer();
    $parser = $container->get('logger.log_message_parser');
    $logger = new \Drush\Log\DrushLog($parser);
    $container->get('logger.factory')->addLogger($logger);
  }

  function contrib_modules_paths() {
    return array(
      $this->conf_path() . '/modules',
      'sites/all/modules',
      'modules',
    );
  }

  /**
   * @return array of strings - paths to directories where contrib
   * themes can be found
   */
  function contrib_themes_paths() {
    return array(
      $this->conf_path() . '/themes',
      'sites/all/themes',
      'themes',
    );
  }

  function bootstrap_drupal_core($drupal_root) {
    $core = DRUPAL_ROOT . '/core';

    return $core;
  }

  function bootstrap_drupal_database_validate() {
    return parent::bootstrap_drupal_database_validate() && $this->bootstrap_drupal_database_has_table('key_value');
  }

  function bootstrap_drupal_database() {
    // D8 omits this bootstrap level as nothing special needs to be done.
    parent::bootstrap_drupal_database();
  }

  function bootstrap_drupal_configuration() {
    $this->request = Request::createFromGlobals();
    $classloader = drush_drupal_load_autoloader(DRUPAL_ROOT);
    $this->kernel = DrupalKernel::createFromRequest($this->request, $classloader, 'prod');

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

    parent::bootstrap_drupal_configuration();
  }

  function bootstrap_drupal_full() {
    if (!drush_get_context('DRUSH_QUIET', FALSE)) {
      ob_start();
    }
    $this->kernel->boot();
    $this->kernel->prepareLegacyRequest($this->request);
    if (!drush_get_context('DRUSH_QUIET', FALSE)) {
      ob_end_clean();
    }

    parent::bootstrap_drupal_full();
  }

  /**
   * {@inheritdoc}
   */
  public function terminate() {
    parent::terminate();

    if ($this->kernel) {
      $response = Response::create('');
      $this->kernel->terminate($this->request, $response);
    }
  }
}