[3.0] [EventDispatcher][Event] removed deprecated setDispatcher and getDispatcher methods.

This commit is contained in:
Abdellatif Ait boudad 2015-01-05 00:09:31 +00:00
parent 7b6f6d7597
commit ba70a484f1
6 changed files with 6 additions and 77 deletions

View File

@ -1,6 +1,12 @@
CHANGELOG
=========
3.0.0
-----
* The methods Event::setDispatcher(), Event::getDispatcher() have been removed.
The event dispatcher is passed to the listener call.
2.5.0
-----

View File

@ -72,36 +72,6 @@ class Event
$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.
*

View File

@ -43,7 +43,6 @@ class EventDispatcher implements EventDispatcherInterface
$event = new Event();
}
$event->setDispatcher($this);
$event->setName($eventName);
if (!isset($this->listeners[$eventName])) {

View File

@ -247,18 +247,6 @@ abstract class AbstractEventDispatcherTest extends \PHPUnit_Framework_TestCase
$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();

View File

@ -164,7 +164,6 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
$dispatcher = new ContainerAwareEventDispatcher($container);
$dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
$event->setDispatcher($dispatcher);
$event->setName('onEvent');
$service

View File

@ -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 @@ class EventTest extends \PHPUnit_Framework_TestCase
protected function tearDown()
{
$this->event = null;
$this->dispatcher = null;
}
public function testIsPropagationStopped()
@ -59,30 +52,4 @@ class EventTest extends \PHPUnit_Framework_TestCase
$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());
}
}