Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ba70a48

Browse filesBrowse files
committed
[3.0] [EventDispatcher][Event] removed deprecated setDispatcher and getDispatcher methods.
1 parent 7b6f6d7 commit ba70a48
Copy full SHA for ba70a48

File tree

6 files changed

+6
-77
lines changed
Filter options

6 files changed

+6
-77
lines changed

‎src/Symfony/Component/EventDispatcher/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
3.0.0
5+
-----
6+
7+
* The methods Event::setDispatcher(), Event::getDispatcher() have been removed.
8+
The event dispatcher is passed to the listener call.
9+
410
2.5.0
511
-----
612

‎src/Symfony/Component/EventDispatcher/Event.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/Event.php
-30Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -72,36 +72,6 @@ public function stopPropagation()
7272
$this->propagationStopped = true;
7373
}
7474

75-
/**
76-
* Stores the EventDispatcher that dispatches this Event.
77-
*
78-
* @param EventDispatcherInterface $dispatcher
79-
*
80-
* @deprecated since version 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call.
81-
*
82-
* @api
83-
*/
84-
public function setDispatcher(EventDispatcherInterface $dispatcher)
85-
{
86-
$this->dispatcher = $dispatcher;
87-
}
88-
89-
/**
90-
* Returns the EventDispatcher that dispatches this Event.
91-
*
92-
* @return EventDispatcherInterface
93-
*
94-
* @deprecated since version 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call.
95-
*
96-
* @api
97-
*/
98-
public function getDispatcher()
99-
{
100-
trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0. The event dispatcher instance can be received in the listener call instead.', E_USER_DEPRECATED);
101-
102-
return $this->dispatcher;
103-
}
104-
10575
/**
10676
* Gets the event's name.
10777
*

‎src/Symfony/Component/EventDispatcher/EventDispatcher.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/EventDispatcher.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public function dispatch($eventName, Event $event = null)
4343
$event = new Event();
4444
}
4545

46-
$event->setDispatcher($this);
4746
$event->setName($eventName);
4847

4948
if (!isset($this->listeners[$eventName])) {

‎src/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php
-12Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -247,18 +247,6 @@ public function testRemoveSubscriberWithMultipleListeners()
247247
$this->assertFalse($this->dispatcher->hasListeners(self::preFoo));
248248
}
249249

250-
public function testLegacyEventReceivesTheDispatcherInstance()
251-
{
252-
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
253-
254-
$dispatcher = null;
255-
$this->dispatcher->addListener('test', function ($event) use (&$dispatcher) {
256-
$dispatcher = $event->getDispatcher();
257-
});
258-
$this->dispatcher->dispatch('test');
259-
$this->assertSame($this->dispatcher, $dispatcher);
260-
}
261-
262250
public function testEventReceivesTheDispatcherInstanceAsArgument()
263251
{
264252
$listener = new TestWithDispatcher();

‎src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ public function testHasListenersOnLazyLoad()
164164
$dispatcher = new ContainerAwareEventDispatcher($container);
165165
$dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
166166

167-
$event->setDispatcher($dispatcher);
168167
$event->setName('onEvent');
169168

170169
$service

‎src/Symfony/Component/EventDispatcher/Tests/EventTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/Tests/EventTest.php
-33Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,13 @@ class EventTest extends \PHPUnit_Framework_TestCase
2424
*/
2525
protected $event;
2626

27-
/**
28-
* @var \Symfony\Component\EventDispatcher\EventDispatcher
29-
*/
30-
protected $dispatcher;
31-
3227
/**
3328
* Sets up the fixture, for example, opens a network connection.
3429
* This method is called before a test is executed.
3530
*/
3631
protected function setUp()
3732
{
3833
$this->event = new Event();
39-
$this->dispatcher = new EventDispatcher();
4034
}
4135

4236
/**
@@ -46,7 +40,6 @@ protected function setUp()
4640
protected function tearDown()
4741
{
4842
$this->event = null;
49-
$this->dispatcher = null;
5043
}
5144

5245
public function testIsPropagationStopped()
@@ -59,30 +52,4 @@ public function testStopPropagationAndIsPropagationStopped()
5952
$this->event->stopPropagation();
6053
$this->assertTrue($this->event->isPropagationStopped());
6154
}
62-
63-
public function testLegacySetDispatcher()
64-
{
65-
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
66-
$this->event->setDispatcher($this->dispatcher);
67-
$this->assertSame($this->dispatcher, $this->event->getDispatcher());
68-
}
69-
70-
public function testLegacyGetDispatcher()
71-
{
72-
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
73-
$this->assertNull($this->event->getDispatcher());
74-
}
75-
76-
public function testLegacyGetName()
77-
{
78-
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
79-
$this->assertNull($this->event->getName());
80-
}
81-
82-
public function testLegacySetName()
83-
{
84-
$this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED);
85-
$this->event->setName('foo');
86-
$this->assertEquals('foo', $this->event->getName());
87-
}
8855
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.