function DrupalBoot::drush_command_belongs_to_disabled_module

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

Check if the given command belongs to a disabled module.

Return value

array Array with a command-like bootstrap error or FALSE if Drupal was not bootstrapped fully or the command does not belong to a disabled module.

2 calls to DrupalBoot::drush_command_belongs_to_disabled_module()
DrupalBoot::report_command_error in lib/Drush/Boot/DrupalBoot.php
Called by Drush if a command is not found, or if the command was found, but did not meet requirements.
DrupalBoot::report_command_error in lib/Drush/Boot/DrupalBoot.php
Called by Drush if a command is not found, or if the command was found, but did not meet requirements.

File

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

Namespace

Drush\Boot

Class

DrupalBoot

Code

function drush_command_belongs_to_disabled_module() {
  if (drush_has_boostrapped(DRUSH_BOOTSTRAP_DRUPAL_FULL)) {
    _drush_find_commandfiles(DRUSH_BOOTSTRAP_DRUPAL_SITE, DRUSH_BOOTSTRAP_DRUPAL_CONFIGURATION);
    drush_get_commands(TRUE);
    $commands = drush_get_commands();
    $arguments = drush_get_arguments();
    $command_name = array_shift($arguments);
    if (isset($commands[$command_name])) {
      // We found it. Load its module name and set an error.
      if (is_array($commands[$command_name]['drupal dependencies']) && count($commands[$command_name]['drupal dependencies'])) {
        $modules = implode(', ', $commands[$command_name]['drupal dependencies']);
      }
      else {
        // The command does not define Drupal dependencies. Derive them.
        $command_files = commandfiles_cache()->get();
        $command_path = $commands[$command_name]['path'] . DIRECTORY_SEPARATOR . $commands[$command_name]['commandfile'] . '.drush.inc';
        $modules = array_search($command_path, $command_files);
      }
      return array(
        'bootstrap_errors' => array(
          'DRUSH_COMMAND_DEPENDENCY_ERROR' => dt('Command !command needs the following module(s) enabled to run: !dependencies.', array(
            '!command' => $command_name,
            '!dependencies' => $modules,
          )),
        ),
      );
    }
  }

  return FALSE;
}