function drush_bootstrap_validate

8.0.x bootstrap.inc drush_bootstrap_validate($phase)
6.x bootstrap.inc drush_bootstrap_validate($phase)
7.x bootstrap.inc drush_bootstrap_validate($phase)
3.x environment.inc drush_bootstrap_validate($phase)
4.x environment.inc drush_bootstrap_validate($phase)
5.x bootstrap.inc drush_bootstrap_validate($phase)
master bootstrap.inc drush_bootstrap_validate($phase)

Validate whether a bootstrap phase can be reached.

This function will validate the settings that will be used during the actual bootstrap process, and allow commands to progressively bootstrap to the highest level that can be reached.

This function will only run the validation function once, and store the result from that execution in a local static. This avoids validating phases multiple times.

Parameters

phase: The bootstrap phase to validate to. @see \Drush\Boot::bootstrap_phases

Return value

True if bootstrap is possible, False if the validation failed.

3 calls to drush_bootstrap_validate()
drush_bootstrap in includes/bootstrap.inc
Bootstrap Drush to the desired phase.
drush_bootstrap_max in includes/bootstrap.inc
Bootstrap to the highest level possible, without triggering any errors.
drush_bootstrap_to_phase in includes/bootstrap.inc
Bootstrap to the specified phase.

File

includes/bootstrap.inc, line 395

Code

function drush_bootstrap_validate($phase) {
  $bootstrap = drush_get_bootstrap_object();
  $phases = _drush_bootstrap_phases(TRUE);
  static $result_cache = array();

  if (!array_key_exists($phase, $result_cache)) {
    drush_set_context('DRUSH_BOOTSTRAP_ERRORS', array());
    drush_set_context('DRUSH_BOOTSTRAP_VALUES', array());

    foreach ($phases as $phase_index => $current_phase) {
      $validated_phase = drush_get_context('DRUSH_BOOTSTRAP_VALIDATION_PHASE', -1);
      if ($phase_index > $phase) {
        break;
      }
      if ($phase_index > $validated_phase) {
        $current_phase .= '_validate';
        if (method_exists($bootstrap, $current_phase)) {
          $result_cache[$phase_index] = $bootstrap->{$current_phase}();
        }
        else {
          $result_cache[$phase_index] = TRUE;
        }
        drush_set_context('DRUSH_BOOTSTRAP_VALIDATION_PHASE', $phase_index);
      }
    }
  }
  return $result_cache[$phase];
}