/** * Calls a Drush command. * * This is an exact copy of drush_main from drush.php, but that file * cannot be loaded because it produces side effects. * * @see drush_main * * @return int|string */ protected static function drushMain() { $return = ''; // Start code coverage collection. if ($coverage_file = drush_get_option('drush-coverage', false)) { drush_set_context('DRUSH_CODE_COVERAGE', $coverage_file); xdebug_start_code_coverage(XDEBUG_CC_UNUSED | XDEBUG_CC_DEAD_CODE); register_shutdown_function('drush_coverage_shutdown'); } /* Set up bootstrap object, so that * - 'early' files can bootstrap when needed. * - bootstrap constants are available. */ $bootstrap_class = drush_get_option('bootstrap_class', 'Drush\\Boot\\DrupalBoot'); $bootstrap = new $bootstrap_class(); drush_set_context('DRUSH_BOOTSTRAP_OBJECT', $bootstrap); $bootstrap->preflight(); // Process initial global options such as --debug. _drush_preflight_global_options(); $return = ''; drush_preflight(); if (!drush_get_error()) { if ($file = drush_get_option('early', false)) { require_once $file; $function = 'drush_early_' . basename($file, '.inc'); if (function_exists($function)) { if ($return = $function()) { // If the function returns FALSE, we continue and attempt to bootstrap // as normal. Otherwise, we exit early with the returned output. if ($return === TRUE) { $return = ''; } } } } else { // Do any necessary preprocessing operations on the command, // perhaps handling immediately. $command_handled = drush_preflight_command_dispatch(); if (!$command_handled) { $bootstrap = drush_get_context('DRUSH_BOOTSTRAP_OBJECT'); $return = $bootstrap->bootstrap_and_dispatch(); } } } drush_postflight(); // How strict are we? If we are very strict, turn 'ok' into 'error' // if there are any warnings in the log. if ($return == 0 && drush_get_option('strict') > 1 && drush_log_has_errors()) { $return = 1; } // After this point the drush_shutdown function will run, // exiting with the correct exit code. return $return; }
/** * Execute the BackdropBoot::BOOTSTRAP_SITE phase. * * Initialize a site on the Backdrop root. * * We now set various contexts that we determined and confirmed to be valid. * Additionally we load an optional drushrc.php file in the site directory. */ function bootstrap_backdrop_site() { drush_load_config('site'); $drush_uri = drush_get_context('DRUSH_SELECTED_URI'); drush_set_context('DRUSH_URI', $drush_uri); $site = drush_set_context('DRUSH_BACKDROP_SITE', drush_bootstrap_value('site')); $conf_path = drush_set_context('DRUSH_BACKDROP_SITE_ROOT', drush_bootstrap_value('conf_path')); drush_log(dt("Initialized Backdrop site !site at !site_root", array('!site' => $site, '!site_root' => $conf_path))); _drush_preflight_global_options(); }
/** * Called by bootstrap_drupal_site to do the main work * of the drush drupal site bootstrap. */ function bootstrap_do_drupal_site() { $drush_uri = drush_get_context('DRUSH_SELECTED_URI'); drush_set_context('DRUSH_URI', $drush_uri); $site = drush_set_context('DRUSH_DRUPAL_SITE', drush_bootstrap_value('site')); $conf_path = drush_set_context('DRUSH_DRUPAL_SITE_ROOT', drush_bootstrap_value('conf_path')); drush_log(dt("Initialized Drupal site !site at !site_root", array('!site' => $site, '!site_root' => $conf_path))); _drush_preflight_global_options(); }