You are here

public function DevelCommands::hookInteract in Devel 8

Same name and namespace in other branches
  1. 8.3 src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::hookInteract()
  2. 8.2 src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::hookInteract()
  3. 4.x src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::hookInteract()

@hook interact hook

File

src/Commands/DevelCommands.php, line 104

Class

DevelCommands
For commands that are parts of modules, Drush expects to find commandfiles in __MODULE__/src/Commands, and the namespace is Drupal/__MODULE__/Commands.

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'));
    }
  }
}