diff --git a/src/Symfony/Component/EventDispatcher/CHANGELOG.md b/src/Symfony/Component/EventDispatcher/CHANGELOG.md index bb42ee19c04ca..5057ca137912c 100644 --- a/src/Symfony/Component/EventDispatcher/CHANGELOG.md +++ b/src/Symfony/Component/EventDispatcher/CHANGELOG.md @@ -1,6 +1,13 @@ CHANGELOG ========= +3.0.0 +----- + + * The methods Event::setDispatcher(), Event::getDispatcher(), Event::setName() + and Event::setName() have been removed. + The event dispatcher and name is passed to the listener call. + 2.5.0 ----- diff --git a/src/Symfony/Component/EventDispatcher/Event.php b/src/Symfony/Component/EventDispatcher/Event.php index e411ca81360ad..7b87c50977b31 100644 --- a/src/Symfony/Component/EventDispatcher/Event.php +++ b/src/Symfony/Component/EventDispatcher/Event.php @@ -34,16 +34,6 @@ class Event */ private $propagationStopped = false; - /** - * @var EventDispatcher Dispatcher that dispatched this event - */ - private $dispatcher; - - /** - * @var string This event's name - */ - private $name; - /** * Returns whether further event listeners should be triggered. * @@ -71,64 +61,4 @@ public function stopPropagation() { $this->propagationStopped = true; } - - /** - * Stores the EventDispatcher that dispatches this Event. - * - * @param EventDispatcherInterface $dispatcher - * - * @deprecated since version 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call. - * - * @api - */ - public function setDispatcher(EventDispatcherInterface $dispatcher) - { - $this->dispatcher = $dispatcher; - } - - /** - * Returns the EventDispatcher that dispatches this Event. - * - * @return EventDispatcherInterface - * - * @deprecated since version 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call. - * - * @api - */ - public function getDispatcher() - { - 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); - - return $this->dispatcher; - } - - /** - * Gets the event's name. - * - * @return string - * - * @deprecated since version 2.4, to be removed in 3.0. The event name is passed to the listener call. - * - * @api - */ - public function getName() - { - trigger_error('The '.__METHOD__.' method is deprecated since version 2.4 and will be removed in 3.0. The event name can be received in the listener call instead.', E_USER_DEPRECATED); - - return $this->name; - } - - /** - * Sets the event's name property. - * - * @param string $name The event name. - * - * @deprecated since version 2.4, to be removed in 3.0. The event name is passed to the listener call. - * - * @api - */ - public function setName($name) - { - $this->name = $name; - } } diff --git a/src/Symfony/Component/EventDispatcher/EventDispatcher.php b/src/Symfony/Component/EventDispatcher/EventDispatcher.php index 3b032fb081e34..28db02271622a 100644 --- a/src/Symfony/Component/EventDispatcher/EventDispatcher.php +++ b/src/Symfony/Component/EventDispatcher/EventDispatcher.php @@ -43,9 +43,6 @@ public function dispatch($eventName, Event $event = null) $event = new Event(); } - $event->setDispatcher($this); - $event->setName($eventName); - if (!isset($this->listeners[$eventName])) { return $event; } diff --git a/src/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php index d3278046fe84d..fa4bbbbfbec63 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php @@ -121,15 +121,6 @@ public function testDispatch() $this->assertSame($event, $return); } - public function testLegacyDispatch() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $event = new Event(); - $return = $this->dispatcher->dispatch(self::preFoo, $event); - $this->assertEquals('pre.foo', $event->getName()); - } - public function testDispatchForClosure() { $invoked = 0; @@ -247,18 +238,6 @@ public function testRemoveSubscriberWithMultipleListeners() $this->assertFalse($this->dispatcher->hasListeners(self::preFoo)); } - public function testLegacyEventReceivesTheDispatcherInstance() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $dispatcher = null; - $this->dispatcher->addListener('test', function ($event) use (&$dispatcher) { - $dispatcher = $event->getDispatcher(); - }); - $this->dispatcher->dispatch('test'); - $this->assertSame($this->dispatcher, $dispatcher); - } - public function testEventReceivesTheDispatcherInstanceAsArgument() { $listener = new TestWithDispatcher(); diff --git a/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php index 6f2fbcb9df9ad..24a04d9862462 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php @@ -164,9 +164,6 @@ public function testHasListenersOnLazyLoad() $dispatcher = new ContainerAwareEventDispatcher($container); $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - $event->setDispatcher($dispatcher); - $event->setName('onEvent'); - $service ->expects($this->once()) ->method('onEvent') diff --git a/src/Symfony/Component/EventDispatcher/Tests/EventTest.php b/src/Symfony/Component/EventDispatcher/Tests/EventTest.php index 8f2fb7358e325..272ab17e8a091 100644 --- a/src/Symfony/Component/EventDispatcher/Tests/EventTest.php +++ b/src/Symfony/Component/EventDispatcher/Tests/EventTest.php @@ -24,11 +24,6 @@ class EventTest extends \PHPUnit_Framework_TestCase */ protected $event; - /** - * @var \Symfony\Component\EventDispatcher\EventDispatcher - */ - protected $dispatcher; - /** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. @@ -36,7 +31,6 @@ class EventTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->event = new Event(); - $this->dispatcher = new EventDispatcher(); } /** @@ -46,7 +40,6 @@ protected function setUp() protected function tearDown() { $this->event = null; - $this->dispatcher = null; } public function testIsPropagationStopped() @@ -59,30 +52,4 @@ public function testStopPropagationAndIsPropagationStopped() $this->event->stopPropagation(); $this->assertTrue($this->event->isPropagationStopped()); } - - public function testLegacySetDispatcher() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - $this->event->setDispatcher($this->dispatcher); - $this->assertSame($this->dispatcher, $this->event->getDispatcher()); - } - - public function testLegacyGetDispatcher() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - $this->assertNull($this->event->getDispatcher()); - } - - public function testLegacyGetName() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - $this->assertNull($this->event->getName()); - } - - public function testLegacySetName() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - $this->event->setName('foo'); - $this->assertEquals('foo', $this->event->getName()); - } }