/** * 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. */ function bootstrap_drupal_configuration() { global $conf; $override = array('dev_query' => FALSE, 'cron_safe_threshold' => 0); $current_override = drush_get_option_list('variables'); foreach ($current_override as $name => $value) { if (is_numeric($name) && strpos($value, '=') !== FALSE) { list($name, $value) = explode('=', $value, 2); } $override[$name] = $value; } $conf = is_array($conf) ? array_merge($conf, $override) : $conf; }
function commandfile_searchpaths($phase, $phase_max = FALSE) { if (!$phase_max) { $phase_max = $phase; } $searchpath = array(); switch ($phase) { case BackdropBoot::BOOTSTRAP_ROOT: $backdrop_root = drush_get_context('DRUSH_SELECTED_BACKDROP_ROOT'); $searchpath[] = $backdrop_root . '/../drush'; $searchpath[] = $backdrop_root . '/drush'; $searchpath[] = $backdrop_root . '/sites/all/drush'; // Add the drupalboot.drush.inc commandfile. // $searchpath[] = __DIR__; break; case BackdropBoot::BOOTSTRAP_SITE: // If we are going to stop bootstrapping at the site, then // we will quickly add all commandfiles that we can find for // any extension associated with the site, whether it is enabled // or not. If we are, however, going to continue on to bootstrap // all the way to DRUSH_BOOTSTRAP_DRUPAL_FULL, then we will // instead wait for that phase, which will more carefully add // only those Drush commandfiles that are associated with // enabled modules. if ($phase_max < BackdropBoot::BOOTSTRAP_FULL) { $searchpath = array_merge($searchpath, $this->contrib_modules_paths()); // Adding commandfiles located within /profiles. Try to limit to one // profile for speed. Note that Backdrop allows enabling modules from // a non-active profile so this logic is kinda dodgy. $cid = $this->install_profile_cid(); if ($cached = drush_cache_get($cid)) { $profile = $cached->data; $searchpath[] = "profiles/{$profile}/modules"; $searchpath[] = "profiles/{$profile}/themes"; } else { // If install_profile is not available, scan all profiles. $searchpath[] = "profiles"; $searchpath[] = "sites/all/profiles"; } $searchpath = array_merge($searchpath, $this->contrib_themes_paths()); } break; case BackdropBoot::BOOTSTRAP_CONFIGURATION: // Nothing to do here anymore. Left for documentation. break; case BackdropBoot::BOOTSTRAP_FULL: // Add enabled module paths, excluding the install profile. Since we are // bootstrapped we can use the Backdrop API. $ignored_modules = drush_get_option_list('ignored-modules', array()); $cid = $this->install_profile_cid(); if ($cached = drush_cache_get($cid)) { $ignored_modules[] = $cached->data; } foreach (array_diff($this->module_list(), $ignored_modules) as $module) { $filepath = backdrop_get_path('module', $module); if ($filepath && $filepath != '/') { $searchpath[] = $filepath; } } $searchpath[] = backdrop_get_path('theme', config_get('system.core', 'theme_default')); $searchpath[] = backdrop_get_path('theme', config_get('system.core', 'theme_admin')); break; } return $searchpath; }
function bootstrap_drupal_full() { drush_log(dt('About to bootstrap the Drupal 8 Kernel.'), LogLevel::DEBUG); // TODO: do we need to do ob_start any longer? if (!drush_get_context('DRUSH_QUIET', FALSE)) { ob_start(); } $this->kernel->invalidateContainer(); $this->kernel->boot(); $this->kernel->prepareLegacyRequest($this->request); if (!drush_get_context('DRUSH_QUIET', FALSE)) { ob_end_clean(); } drush_log(dt('Finished bootstraping the Drupal 8 Kernel.'), LogLevel::DEBUG); parent::bootstrap_drupal_full(); // Get a list of the modules to ignore $ignored_modules = drush_get_option_list('ignored-modules', array()); // We have to get the service command list from the container, because // it is constructed in an indirect way during the container initialization. // The upshot is that the list of console commands is not available // until after $kernel->boot() is called. $container = \Drupal::getContainer(); $serviceCommandlist = $container->get('drush.service.consolecommands'); foreach ($serviceCommandlist->getCommandList() as $command) { if (!$this->commandIgnored($command, $ignored_modules)) { drush_log(dt('Add a command: !name', ['!name' => $command->getName()]), LogLevel::DEBUG); drush_add_command_to_application(\Drush::getContainer(), $command); } } // Do the same thing with the annotation commands. $serviceCommandlist = $container->get('drush.service.consolidationcommands'); foreach ($serviceCommandlist->getCommandList() as $commandhandler) { if (!$this->commandIgnored($commandhandler, $ignored_modules)) { drush_log(dt('Add a commandhandler: !name', ['!name' => get_class($commandhandler)]), LogLevel::DEBUG); drush_create_commands_from_command_instance(\Drush::getContainer(), $commandhandler); } } }