You are here

public function DevelCommands::hookInteract in Devel 8.3

Same name and namespace in other branches
  1. 8 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 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'));
    }
  }
}