Mercurial > hg > cmmr2012-drupal-site
comparison vendor/symfony/http-kernel/DataCollector/EventDataCollector.php @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children | a9cd425dd02b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 <?php | |
2 | |
3 /* | |
4 * This file is part of the Symfony package. | |
5 * | |
6 * (c) Fabien Potencier <fabien@symfony.com> | |
7 * | |
8 * For the full copyright and license information, please view the LICENSE | |
9 * file that was distributed with this source code. | |
10 */ | |
11 | |
12 namespace Symfony\Component\HttpKernel\DataCollector; | |
13 | |
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; | |
18 | |
19 /** | |
20 * EventDataCollector. | |
21 * | |
22 * @author Fabien Potencier <fabien@symfony.com> | |
23 */ | |
24 class EventDataCollector extends DataCollector implements LateDataCollectorInterface | |
25 { | |
26 protected $dispatcher; | |
27 | |
28 public function __construct(EventDispatcherInterface $dispatcher = null) | |
29 { | |
30 if ($dispatcher instanceof TraceableEventDispatcherInterface && !method_exists($dispatcher, 'reset')) { | |
31 @trigger_error(sprintf('Implementing "%s" without the "reset()" method is deprecated since Symfony 3.4 and will be unsupported in 4.0 for class "%s".', TraceableEventDispatcherInterface::class, \get_class($dispatcher)), E_USER_DEPRECATED); | |
32 } | |
33 $this->dispatcher = $dispatcher; | |
34 } | |
35 | |
36 /** | |
37 * {@inheritdoc} | |
38 */ | |
39 public function collect(Request $request, Response $response, \Exception $exception = null) | |
40 { | |
41 $this->data = array( | |
42 'called_listeners' => array(), | |
43 'not_called_listeners' => array(), | |
44 ); | |
45 } | |
46 | |
47 public function reset() | |
48 { | |
49 $this->data = array(); | |
50 | |
51 if ($this->dispatcher instanceof TraceableEventDispatcherInterface) { | |
52 if (!method_exists($this->dispatcher, 'reset')) { | |
53 return; // @deprecated | |
54 } | |
55 | |
56 $this->dispatcher->reset(); | |
57 } | |
58 } | |
59 | |
60 public function lateCollect() | |
61 { | |
62 if ($this->dispatcher instanceof TraceableEventDispatcherInterface) { | |
63 $this->setCalledListeners($this->dispatcher->getCalledListeners()); | |
64 $this->setNotCalledListeners($this->dispatcher->getNotCalledListeners()); | |
65 } | |
66 $this->data = $this->cloneVar($this->data); | |
67 } | |
68 | |
69 /** | |
70 * Sets the called listeners. | |
71 * | |
72 * @param array $listeners An array of called listeners | |
73 * | |
74 * @see TraceableEventDispatcherInterface | |
75 */ | |
76 public function setCalledListeners(array $listeners) | |
77 { | |
78 $this->data['called_listeners'] = $listeners; | |
79 } | |
80 | |
81 /** | |
82 * Gets the called listeners. | |
83 * | |
84 * @return array An array of called listeners | |
85 * | |
86 * @see TraceableEventDispatcherInterface | |
87 */ | |
88 public function getCalledListeners() | |
89 { | |
90 return $this->data['called_listeners']; | |
91 } | |
92 | |
93 /** | |
94 * Sets the not called listeners. | |
95 * | |
96 * @param array $listeners An array of not called listeners | |
97 * | |
98 * @see TraceableEventDispatcherInterface | |
99 */ | |
100 public function setNotCalledListeners(array $listeners) | |
101 { | |
102 $this->data['not_called_listeners'] = $listeners; | |
103 } | |
104 | |
105 /** | |
106 * Gets the not called listeners. | |
107 * | |
108 * @return array An array of not called listeners | |
109 * | |
110 * @see TraceableEventDispatcherInterface | |
111 */ | |
112 public function getNotCalledListeners() | |
113 { | |
114 return $this->data['not_called_listeners']; | |
115 } | |
116 | |
117 /** | |
118 * {@inheritdoc} | |
119 */ | |
120 public function getName() | |
121 { | |
122 return 'events'; | |
123 } | |
124 } |