annotate vendor/symfony/http-kernel/DataCollector/EventDataCollector.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 1fec387a4317
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 /*
Chris@0 4 * This file is part of the Symfony package.
Chris@0 5 *
Chris@0 6 * (c) Fabien Potencier <fabien@symfony.com>
Chris@0 7 *
Chris@0 8 * For the full copyright and license information, please view the LICENSE
Chris@0 9 * file that was distributed with this source code.
Chris@0 10 */
Chris@0 11
Chris@0 12 namespace Symfony\Component\HttpKernel\DataCollector;
Chris@0 13
Chris@0 14 use Symfony\Component\HttpFoundation\Request;
Chris@0 15 use Symfony\Component\HttpFoundation\Response;
Chris@0 16 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
Chris@0 17 use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface;
Chris@0 18
Chris@0 19 /**
Chris@0 20 * EventDataCollector.
Chris@0 21 *
Chris@0 22 * @author Fabien Potencier <fabien@symfony.com>
Chris@0 23 */
Chris@0 24 class EventDataCollector extends DataCollector implements LateDataCollectorInterface
Chris@0 25 {
Chris@0 26 protected $dispatcher;
Chris@0 27
Chris@0 28 public function __construct(EventDispatcherInterface $dispatcher = null)
Chris@0 29 {
Chris@0 30 $this->dispatcher = $dispatcher;
Chris@0 31 }
Chris@0 32
Chris@0 33 /**
Chris@0 34 * {@inheritdoc}
Chris@0 35 */
Chris@0 36 public function collect(Request $request, Response $response, \Exception $exception = null)
Chris@0 37 {
Chris@0 38 $this->data = array(
Chris@0 39 'called_listeners' => array(),
Chris@0 40 'not_called_listeners' => array(),
Chris@0 41 );
Chris@0 42 }
Chris@0 43
Chris@0 44 public function lateCollect()
Chris@0 45 {
Chris@0 46 if ($this->dispatcher instanceof TraceableEventDispatcherInterface) {
Chris@0 47 $this->setCalledListeners($this->dispatcher->getCalledListeners());
Chris@0 48 $this->setNotCalledListeners($this->dispatcher->getNotCalledListeners());
Chris@0 49 }
Chris@0 50 }
Chris@0 51
Chris@0 52 /**
Chris@0 53 * Sets the called listeners.
Chris@0 54 *
Chris@0 55 * @param array $listeners An array of called listeners
Chris@0 56 *
Chris@0 57 * @see TraceableEventDispatcherInterface
Chris@0 58 */
Chris@0 59 public function setCalledListeners(array $listeners)
Chris@0 60 {
Chris@0 61 $this->data['called_listeners'] = $listeners;
Chris@0 62 }
Chris@0 63
Chris@0 64 /**
Chris@0 65 * Gets the called listeners.
Chris@0 66 *
Chris@0 67 * @return array An array of called listeners
Chris@0 68 *
Chris@0 69 * @see TraceableEventDispatcherInterface
Chris@0 70 */
Chris@0 71 public function getCalledListeners()
Chris@0 72 {
Chris@0 73 return $this->data['called_listeners'];
Chris@0 74 }
Chris@0 75
Chris@0 76 /**
Chris@0 77 * Sets the not called listeners.
Chris@0 78 *
Chris@0 79 * @param array $listeners An array of not called listeners
Chris@0 80 *
Chris@0 81 * @see TraceableEventDispatcherInterface
Chris@0 82 */
Chris@0 83 public function setNotCalledListeners(array $listeners)
Chris@0 84 {
Chris@0 85 $this->data['not_called_listeners'] = $listeners;
Chris@0 86 }
Chris@0 87
Chris@0 88 /**
Chris@0 89 * Gets the not called listeners.
Chris@0 90 *
Chris@0 91 * @return array An array of not called listeners
Chris@0 92 *
Chris@0 93 * @see TraceableEventDispatcherInterface
Chris@0 94 */
Chris@0 95 public function getNotCalledListeners()
Chris@0 96 {
Chris@0 97 return $this->data['not_called_listeners'];
Chris@0 98 }
Chris@0 99
Chris@0 100 /**
Chris@0 101 * {@inheritdoc}
Chris@0 102 */
Chris@0 103 public function getName()
Chris@0 104 {
Chris@0 105 return 'events';
Chris@0 106 }
Chris@0 107 }