function DrupalBoot::bootstrap_drupal_root_validate

8.0.x DrupalBoot.php DrupalBoot::bootstrap_drupal_root_validate()
7.x DrupalBoot.php DrupalBoot::bootstrap_drupal_root_validate()
master DrupalBoot.php DrupalBoot::bootstrap_drupal_root_validate()

Validate the DRUSH_BOOTSTRAP_DRUPAL_ROOT phase.

In this function, we will check if a valid Drupal directory is available. We also determine the value that will be stored in the DRUSH_DRUPAL_ROOT context and DRUPAL_ROOT constant if it is considered a valid option.

File

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

Namespace

Drush\Boot

Class

DrupalBoot

Code

function bootstrap_drupal_root_validate() {
  $drupal_root = drush_get_context('DRUSH_SELECTED_DRUPAL_ROOT');

  if (empty($drupal_root)) {
    return drush_bootstrap_error('DRUSH_NO_DRUPAL_ROOT', dt("A Drupal installation directory could not be found"));
  }
  if (!$signature = drush_valid_root($drupal_root)) {
    return drush_bootstrap_error('DRUSH_INVALID_DRUPAL_ROOT', dt("The directory !drupal_root does not contain a valid Drupal installation", array('!drupal_root' => $drupal_root)));
  }

  $version = drush_drupal_version($drupal_root);
  $major_version = drush_drupal_major_version($drupal_root);
  if ($major_version <= 5) {
    return drush_set_error('DRUSH_DRUPAL_VERSION_UNSUPPORTED', dt('Drush !drush_version does not support Drupal !major_version.', array('!drush_version' => DRUSH_VERSION, '!major_version' => $major_version)));
  }

  drush_bootstrap_value('drupal_root', realpath($drupal_root));
  define('DRUSH_DRUPAL_SIGNATURE', $signature);

  return TRUE;
}