public function DevelCommands::interactEvent in Devel 8.2
Same name and namespace in other branches
- 8.3 src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::interactEvent()
- 8 src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::interactEvent()
- 4.x src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::interactEvent()
@hook interact devel:event
File
- src/
Commands/ DevelCommands.php, line 139
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\CommandsCode
public function interactEvent(Input $input, Output $output) {
$dispatcher = $this
->getEventDispatcher();
if (!$input
->getArgument('event')) {
// @todo Expand this list.
$events = array(
'kernel.controller',
'kernel.exception',
'kernel.request',
'kernel.response',
'kernel.terminate',
'kernel.view',
);
$events = array_combine($events, $events);
if (!($event = $this
->io()
->choice('Enter the event you wish to explore.', $events))) {
throw new UserAbortException();
}
$input
->setArgument('event', $event);
}
if ($implementations = $dispatcher
->getListeners($event)) {
foreach ($implementations as $implementation) {
$callable = get_class($implementation[0]) . '::' . $implementation[1];
$choices[$callable] = $callable;
}
if (!($choice = $this
->io()
->choice('Enter the number of the implementation you wish to view.', $choices))) {
throw new UserAbortException();
}
$input
->setArgument('implementation', $choice);
}
else {
throw new \Exception(dt('No implementations.'));
}
}