4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\HttpKernel\DataCollector;
14 use Symfony\Component\HttpFoundation\Request;
15 use Symfony\Component\HttpFoundation\Response;
16 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
17 use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface;
22 * @author Fabien Potencier <fabien@symfony.com>
24 class EventDataCollector extends DataCollector implements LateDataCollectorInterface
26 protected $dispatcher;
28 public function __construct(EventDispatcherInterface $dispatcher = null)
30 $this->dispatcher = $dispatcher;
36 public function collect(Request $request, Response $response, \Exception $exception = null)
39 'called_listeners' => array(),
40 'not_called_listeners' => array(),
44 public function lateCollect()
46 if ($this->dispatcher instanceof TraceableEventDispatcherInterface) {
47 $this->setCalledListeners($this->dispatcher->getCalledListeners());
48 $this->setNotCalledListeners($this->dispatcher->getNotCalledListeners());
53 * Sets the called listeners.
55 * @param array $listeners An array of called listeners
57 * @see TraceableEventDispatcherInterface
59 public function setCalledListeners(array $listeners)
61 $this->data['called_listeners'] = $listeners;
65 * Gets the called listeners.
67 * @return array An array of called listeners
69 * @see TraceableEventDispatcherInterface
71 public function getCalledListeners()
73 return $this->data['called_listeners'];
77 * Sets the not called listeners.
79 * @param array $listeners An array of not called listeners
81 * @see TraceableEventDispatcherInterface
83 public function setNotCalledListeners(array $listeners)
85 $this->data['not_called_listeners'] = $listeners;
89 * Gets the not called listeners.
91 * @return array An array of not called listeners
93 * @see TraceableEventDispatcherInterface
95 public function getNotCalledListeners()
97 return $this->data['not_called_listeners'];
103 public function getName()