public function DevelCommands::interactEvent in Devel 4.x
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()
- 8.2 src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::interactEvent()
@hook interact devel:event
File
- src/
Commands/ DevelCommands.php, line 176
Class
- DevelCommands
- Class DevelCommands.
Namespace
Drupal\devel\CommandsCode
public function interactEvent(Input $input, Output $output) {
$dispatcher = $this
->getEventDispatcher();
$event = $input
->getArgument('event');
if (!$event) {
// @todo Expand this list.
$events = [
'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.'));
}
}