function DevelCommands::interactEvent
Same name in this branch
- 5.x src/Drush/Commands/DevelCommands.php \Drupal\devel\Drush\Commands\DevelCommands::interactEvent()
Same name in other branches
- 4.x src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::interactEvent()
Asks the user to select an event and the event's implementation.
@hook interact devel:event
File
-
src/
Commands/ DevelCommands.php, line 197
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.'));
}
}