function DevelCommands::interactEvent
Same name in this branch
- 5.x src/Commands/DevelCommands.php \Drupal\devel\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.
File
-
src/
Drush/ Commands/ DevelCommands.php, line 177
Class
Namespace
Drupal\devel\Drush\CommandsCode
public function interactEvent(Input $input, Output $output) : void {
$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()
->select('Enter the event you wish to explore.', $events))) {
throw new UserAbortException();
}
$input->setArgument('event', $event);
}
/** @var \Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher $event_dispatcher */
$event_dispatcher = $this->eventDispatcher;
if ($implementations = $event_dispatcher->getListeners($event)) {
$choices = [];
foreach ($implementations as $implementation) {
$callable = $implementation[0]::class . '::' . $implementation[1];
$choices[$callable] = $callable;
}
if (!($choice = $this->io()
->select('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.'));
}
}