5 * Contains Drupal\Console\Command\Shared\EventsTrait.
8 namespace Drupal\Console\Command\Shared;
13 * @package Drupal\Console\Command
20 public function eventsQuestion()
22 $eventCollection = [];
23 $this->getIo()->info($this->trans('commands.common.questions.events.message'));
25 $events = $this->getEvents();
28 $event = $this->getIo()->choiceNoList(
29 $this->trans('commands.common.questions.events.name'),
35 if (empty($event) || is_numeric($event)) {
39 $callbackSuggestion = str_replace('.', '_', $event);
40 $callback = $this->getIo()->ask(
41 $this->trans('commands.generate.event.subscriber.questions.callback-name'),
45 $eventCollection[$event] = $callback;
46 $eventKey = array_search($event, $events, true);
49 unset($events[$eventKey]);
53 return $eventCollection;
56 public function getEvents()
58 if (null === $this->events) {
60 $this->events = array_keys($this->eventDispatcher->getListeners());