/** * outputListeners * * @param OutputInterface $output Output * @param array $options array of options from the console * */ protected function outputListeners(OutputInterface $output, $options = array()) { $fetcher = new ListenerFetcher($this->getContainerBuilder()); $filter = new ListenerFilter(); $listeners = $fetcher->fetchListeners($options['show-private']); if ($options['event']) { $listeners = $filter->filterByEvent($options['event'], $listeners, $options['order-desc']); } if ($options['show-listeners']) { $listeners = $filter->fetchListeners($listeners); } if ($options['show-subscribers']) { $listeners = $filter->fetchSubscribers($listeners); } $label = '<comment>Public</comment> (services) listeners'; if ($options['show-private']) { $label = '<comment>Public</comment> and <comment>private</comment> (services) listeners'; } $output->writeln($this->getHelper('formatter')->formatSection('container', $label)); $table = $this->getHelperSet()->get('table'); $table->setHeaders(array('Name', 'Event', 'Method', 'Priority', 'Type', 'Class Name')); $table->setCellRowFormat('<fg=white>%s</fg=white>'); $table->setRows($listeners); $table->render($output); }
public function testGetOnlySubscribers() { $listeners = array(array(1 => 'event', 4 => 'subscriber'), array(1 => 'event', 4 => 'listener'), array(4 => 'listener')); $filter = new ListenerFilter(); $filtered = $filter->getSubscribers($listeners); $this->assertCount(1, $filtered); $this->assertEquals('subscriber', $filtered[0][4]); }