function DrupalBoot::drush_enforce_requirement_drupal_dependencies

8.0.x DrupalBoot.php DrupalBoot::drush_enforce_requirement_drupal_dependencies(&$command)
7.x DrupalBoot.php DrupalBoot::drush_enforce_requirement_drupal_dependencies(&$command)
master DrupalBoot.php DrupalBoot::drush_enforce_requirement_drupal_dependencies(&$command)

Check that a command has its declared dependencies available or have no dependencies.

Parameters

$command: Command to check. Any errors will be added to the 'bootstrap_errors' element.

Return value

TRUE if command is valid.

1 call to DrupalBoot::drush_enforce_requirement_drupal_dependencies()
DrupalBoot::enforce_requirement in lib/Drush/Boot/DrupalBoot.php
Called by Drush when a command is selected, but before it runs. This gives the Boot class an opportunity to determine if any minimum requirements (e.g. minimum Drupal version) declared in the command have been met.

File

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

Namespace

Drush\Boot

Class

DrupalBoot

Code

function drush_enforce_requirement_drupal_dependencies(&$command) {
  // If the command bootstrap is DRUSH_BOOTSTRAP_MAX, then we will
  // allow the requirements to pass if we have not successfully
  // bootstrapped Drupal.  The combination of DRUSH_BOOTSTRAP_MAX
  // and 'drupal dependencies' indicates that the drush command
  // will use the dependent modules only if they are available.
  if ($command['bootstrap'] == DRUSH_BOOTSTRAP_MAX) {
    // If we have not bootstrapped, then let the dependencies pass;
    // if we have bootstrapped, then enforce them.
    if (drush_get_context('DRUSH_BOOTSTRAP_PHASE') < DRUSH_BOOTSTRAP_DRUPAL_FULL) {
      return TRUE;
    }
  }
  // If there are no drupal dependencies, then do nothing
  if (!empty($command['drupal dependencies'])) {
    foreach ($command['drupal dependencies'] as $dependency) {
      drush_include_engine('drupal', 'environment');
      if (!drush_module_exists($dependency)) {
        $command['bootstrap_errors']['DRUSH_COMMAND_DEPENDENCY_ERROR'] = dt('Command !command needs the following modules installed/enabled to run: !dependencies.', array('!command' => $command['command'], '!dependencies' => implode(', ', $command['drupal dependencies'])));
        return FALSE;
      }
    }
  }
  return TRUE;
}