function DevelCommands::hookInteract

Same name and namespace in other branches
  1. 5.x src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::hookInteract()
  2. 5.x src/Drush/Commands/DevelCommands.php \Drupal\devel\Drush\Commands\DevelCommands::hookInteract()

@hook interact hook

File

src/Commands/DevelCommands.php, line 133

Class

DevelCommands
Class DevelCommands.

Namespace

Drupal\devel\Commands

Code

public function hookInteract(Input $input, Output $output) {
  if (!$input->getArgument('implementation')) {
    if ($hook_implementations = $this->getModuleHandler()
      ->getImplementations($input->getArgument('hook'))) {
      if (!($choice = $this->io()
        ->choice('Enter the number of the hook implementation you wish to view.', array_combine($hook_implementations, $hook_implementations)))) {
        throw new UserAbortException();
      }
      $input->setArgument('implementation', $choice);
    }
    else {
      throw new \Exception(dt('No implementations'));
    }
  }
}