function _drush_bootstrap_drupal_root_validate

6.x bootstrap.inc _drush_bootstrap_drupal_root_validate()
3.x environment.inc _drush_bootstrap_drupal_root_validate()
4.x environment.inc _drush_bootstrap_drupal_root_validate()
5.x bootstrap.inc _drush_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

includes/environment.inc, line 494
Functions used by drush to query the environment and setting the current configuration.

Code

function _drush_bootstrap_drupal_root_validate() {
  $drupal_root = drush_get_option(array('r', 'root'), drush_locate_root());

  if (empty($drupal_root)) {
    return drush_bootstrap_error('DRUSH_NO_DRUPAL_ROOT', dt("A Drupal installation directory could not be found"));
  }
  if (!drush_valid_drupal_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)));
  }

  drush_bootstrap_value('drupal_root', $drupal_root);

  return TRUE;
}