Skip to content

Commit

Permalink
Displays friendly message if the event does not have any registered l…
Browse files Browse the repository at this point in the history
…isteners
  • Loading branch information
Matthieu Auger authored and fabpot committed Mar 26, 2015
1 parent 8f1b757 commit a5628bd
Showing 1 changed file with 16 additions and 2 deletions.
Expand Up @@ -58,14 +58,28 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$dispatcher = $this->getEventDispatcher();

if ($event = $input->getArgument('event')) {
if (!$dispatcher->hasListeners($event)) {
$formatter = $this->getHelperSet()->get('formatter');

$formattedBlock = $formatter->formatBlock(
sprintf('[NOTE] The event "%s" does not have any registered listeners.', $event),
'fg=yellow',
true
);

$output->writeln($formattedBlock);

return;
}

$options = array('event' => $event);
} else {
$options = array();
}

$dispatcher = $this->getEventDispatcher();

$helper = new DescriptorHelper();
$options['format'] = $input->getOption('format');
$options['raw_text'] = $input->getOption('raw');
Expand Down

0 comments on commit a5628bd

Please sign in to comment.