translator = $translator; } /** * @param ConsoleCommandEvent $event */ public function showWelcomeMessage(ConsoleCommandEvent $event) { /* @var Command $command */ $command = $event->getCommand(); /* @var DrupalStyle $io */ $io = new DrupalStyle($event->getInput(), $event->getOutput()); $welcomeMessageKey = 'commands.'.str_replace(':', '.', $command->getName()).'.welcome'; $welcomeMessage = $this->translator->trans($welcomeMessageKey); if ($welcomeMessage != $welcomeMessageKey) { $io->text($welcomeMessage); } } /** * @{@inheritdoc} */ public static function getSubscribedEvents() { return [ConsoleEvents::COMMAND => 'showWelcomeMessage']; } }