5 * Contains Drupal\Console\Command\Shared\EventsTrait.
8 namespace Drupal\Console\Command\Shared;
10 use Drupal\Console\Core\Style\DrupalStyle;
15 * @package Drupal\Console\Command
20 * @param DrupalStyle $io
24 public function eventsQuestion(DrupalStyle $io)
26 $eventCollection = [];
27 $io->info($this->trans('commands.common.questions.events.message'));
29 $events = $this->getEvents();
32 $event = $io->choiceNoList(
33 $this->trans('commands.common.questions.events.name'),
43 $callbackSuggestion = str_replace('.', '_', $event);
45 $this->trans('commands.generate.event.subscriber.questions.callback-name'),
49 $eventCollection[$event] = $callback;
50 $eventKey = array_search($event, $events, true);
53 unset($events[$eventKey]);
57 return $eventCollection;
60 public function getEvents()
62 if (null === $this->events) {
64 $this->events = array_keys($this->eventDispatcher->getListeners());