Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\HttpKernel\DataCollector; Chris@0: Chris@0: use Symfony\Component\HttpFoundation\Request; Chris@0: use Symfony\Component\HttpFoundation\Response; Chris@0: use Symfony\Component\EventDispatcher\EventDispatcherInterface; Chris@0: use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface; Chris@0: Chris@0: /** Chris@0: * EventDataCollector. Chris@0: * Chris@0: * @author Fabien Potencier Chris@0: */ Chris@0: class EventDataCollector extends DataCollector implements LateDataCollectorInterface Chris@0: { Chris@0: protected $dispatcher; Chris@0: Chris@0: public function __construct(EventDispatcherInterface $dispatcher = null) Chris@0: { Chris@0: $this->dispatcher = $dispatcher; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function collect(Request $request, Response $response, \Exception $exception = null) Chris@0: { Chris@0: $this->data = array( Chris@0: 'called_listeners' => array(), Chris@0: 'not_called_listeners' => array(), Chris@0: ); Chris@0: } Chris@0: Chris@0: public function lateCollect() Chris@0: { Chris@0: if ($this->dispatcher instanceof TraceableEventDispatcherInterface) { Chris@0: $this->setCalledListeners($this->dispatcher->getCalledListeners()); Chris@0: $this->setNotCalledListeners($this->dispatcher->getNotCalledListeners()); Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Sets the called listeners. Chris@0: * Chris@0: * @param array $listeners An array of called listeners Chris@0: * Chris@0: * @see TraceableEventDispatcherInterface Chris@0: */ Chris@0: public function setCalledListeners(array $listeners) Chris@0: { Chris@0: $this->data['called_listeners'] = $listeners; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets the called listeners. Chris@0: * Chris@0: * @return array An array of called listeners Chris@0: * Chris@0: * @see TraceableEventDispatcherInterface Chris@0: */ Chris@0: public function getCalledListeners() Chris@0: { Chris@0: return $this->data['called_listeners']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Sets the not called listeners. Chris@0: * Chris@0: * @param array $listeners An array of not called listeners Chris@0: * Chris@0: * @see TraceableEventDispatcherInterface Chris@0: */ Chris@0: public function setNotCalledListeners(array $listeners) Chris@0: { Chris@0: $this->data['not_called_listeners'] = $listeners; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Gets the not called listeners. Chris@0: * Chris@0: * @return array An array of not called listeners Chris@0: * Chris@0: * @see TraceableEventDispatcherInterface Chris@0: */ Chris@0: public function getNotCalledListeners() Chris@0: { Chris@0: return $this->data['not_called_listeners']; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getName() Chris@0: { Chris@0: return 'events'; Chris@0: } Chris@0: }