8000 removed getOrphanedEvents from TraceableEventDispatcherInterface, int… · symfony/symfony@59c8adf · GitHub
[go: up one dir, main page]

Skip to content

Commit 59c8adf

Browse files
committed
removed getOrphanedEvents from TraceableEventDispatcherInterface, introduced interface deprecation
1 parent e637fb3 commit 59c8adf

File tree

7 files changed

+50
-41
lines changed

7 files changed

+50
-41
lines changed

src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
CHANGELOG
22
=========
33

4-
4.0.0
4+
4.1.0
55
-----
66

77
* added information about orphaned events
8+
9+
4.0.0
10+
-----
11+
812
* removed the `WebProfilerExtension::dumpValue()` method
913
* removed the `getTemplates()` method of the `TemplateManager` class in favor of the ``getNames()`` method
1014
* removed the `web_profiler.position` config option and the

src/Symfony/Component/EventDispatcher/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
CHANGELOG
22
=========
33

4+
4.1.0
5+
-----
6+
7+
* The method `TraceableEventDispatcher::getOrphanedEvents()` has been added.
8+
49
4.0.0
510
-----
611

7-
* The method `EventDispatcherInterface::getOrphanedEvents()` has been added.
812
* removed the `ContainerAwareEventDispatcher` class
913
* added the `reset()` method to the `TraceableEventDispatcherInterface`
1014

src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,16 @@ public function getNotCalledListeners()
209209
return $notCalled;
210210
}
211211

212+
/**
213+
* Gets the orphaned events.
214+
*
215+
* @return array An array of orphaned events
216+
*/
217+
public function getOrphanedEvents()
218+
{
219+
return $this->orphanedEvents;
220+
}
221+
212222
public function reset()
213223
{
214224
$this->called = array();
@@ -249,8 +259,10 @@ protected function postDispatch($eventName, Event $event)
249259

250260
private function preProcess($eventName)
251261
{
252-
if (false === $this->dispatcher->hasListeners($eventName)) {
262+
if (!$this->dispatcher->hasListeners($eventName)) {
253263
$this->orphanedEvents[] = $eventName;
264+
265+
return;
254266
}
255267

256268
foreach ($this->dispatcher->getListeners($eventName) as $listener) {
@@ -325,14 +337,4 @@ private function sortListenersByPriority($a, $b)
325337

326338
return 1;
327339
}
328-
329-
/**
330-
* Gets the orphaned events.
331-
*
332-
* @return array An array of orphaned events
333-
*/
334-
public function getOrphanedEvents()
335-
{
336-
return $this->orphanedEvents;
337-
}
338340
}

src/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1515

1616
/**
17+
* @deprecated since version 4.1, will be removed in 5.0.
18+
*
1719
* @author Fabien Potencier <fabien@symfony.com>
1820
*/
1921
interface TraceableEventDispatcherInterface extends EventDispatcherInterface
@@ -36,11 +38,4 @@ public function getNotCalledListeners();
3638
* Resets the trace.
3739
*/
3840
public function reset();
39-
40-
/**
41-
* Gets the orphaned events.
42-
*
43-
* @return array An array of orphaned events
44-
*/
45-
public function getOrphanedEvents();
4641
}

src/Symfony/Component/HttpKernel/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ F438 CHANGELOG
44
4.1.0
55
-----
66

7+
* added orphaned events support to `EventDataCollector`
78
* `ExceptionListener` now logs and collects exceptions at priority `2048` (previously logged at `-128` and collected at `0`)
89

910
4.0.0
@@ -33,7 +34,6 @@ CHANGELOG
3334
3.4.0
3435
-----
3536

36-
* added orphaned events support to `EventDataCollector`
3737
* added a minimalist PSR-3 `Logger` class that writes in `stderr`
3838
* made kernels implementing `CompilerPassInterface` able to process the container
3939
* deprecated bundle inheritance

src/Symfony/Component/HttpKernel/DataCollector/EventDataCollector.php

Lines changed: 22 additions & 17 deletions
F987
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\HttpKernel\DataCollector;
1313

1414
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;
15+
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface;
1516
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
1617
use Symfony\Component\HttpFoundation\Request;
1718
use Symfony\Component\HttpFoundation\Response;
@@ -53,11 +54,15 @@ public function reset()
5354

5455
public function lateCollect()
5556
{
56-
if ($this->dispatcher instanceof TraceableEventDispatcher) {
57+
if ($this->dispatcher instanceof TraceableEventDispatcherInterface) {
5758
$this->setCalledListeners($this->dispatcher->getCalledListeners());
5859
$this->setNotCalledListeners($this->dispatcher->getNotCalledListeners());
60+
}
61+
62+
if ($this->dispatcher instanceof TraceableEventDispatcher) {
5963
$this->setOrphanedEvents($this->dispatcher->getOrphanedEvents());
6064
}
65+
6166
$this->data = $this->cloneVar($this->data);
6267
}
6368

@@ -74,51 +79,51 @@ public function setCalledListeners(array $listeners)
7479
}
7580

7681
/**
77-
* Sets the not called listeners.
82+
* Gets the called listeners.
7883
*
79-
* @param array $listeners An array of not called listeners
84+
* @return array An array of called listeners
8085
*
8186
* @see TraceableEventDispatcher
8287
*/
83-
public function setNotCalledListeners(array $listeners)
88+
public function getCalledListeners()
8489
{
85-
$this->data['not_called_listeners'] = $listeners;
90+
return $this->data['called_listeners'];
8691
}
8792

8893
/**
89-
* Sets the orphaned events.
94+
* Sets the not called listeners.
9095
*
91-
* @param array $events An array of orphaned events
96+
* @param array $listeners
9297
*
9398
* @see TraceableEventDispatcher
9499
*/
95-
public function setOrphanedEvents(array $events)
100+
public function setNotCalledListeners(array $listeners)
96101
{
97-
$this->data['orphaned_events'] = $events;
102+
$this->data['not_called_listeners'] = $listeners;
98103
}
99104

100105
/**
101-
* Gets the called listeners.
106+
* Gets the not called listeners.
102107
*
103-
* @return array An array of called listeners
108+
* @return array
104109
*
105110
* @see TraceableEventDispatcher
106111
*/
107-
public function getCalledListeners()
112+
public function getNotCalledListeners()
108113
{
109-
return $this->data['called_listeners'];
114+
return $this->data['not_called_listeners'];
110115
}
111116

112117
/**
113-
* Gets the not called listeners.
118+
* Sets the orphaned events.
114119
*
115-
* @return array An array of not called listeners
120+
* @param array $events An array of orphaned events
116121
*
117122
* @see TraceableEventDispatcher
118123
*/
119-
public function getNotCalledListeners()
124+
public function setOrphanedEvents(array $events)
120125
{
121-
return $this->data['not_called_listeners'];
126+
$this->data['orphaned_events'] = $events;
122127
}
123128

124129
/**

src/Symfony/Component/HttpKernel/Tests/Fixtures/TestEventDispatcher.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111

1212
namespace Symfony\Component\HttpKernel\Tests\Fixtures;
1313

14-
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcherInterface;
15-
use Symfony\Component\EventDispatcher\EventDispatcher;
14+
use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher;
1615

17-
class TestEventDispatcher extends EventDispatcher implements TraceableEventDispatcherInterface
16+
class TestEventDispatcher extends TraceableEventDispatcher
1817
{
1918
public function getCalledListeners()
2019
{

0 commit comments

Comments
 (0)
0