feature #13260 [3.0][EventDispatcher][Event] removed deprecated methods (aitboudad)
This PR was merged into the 3.0-dev branch. Discussion ---------- [3.0][EventDispatcher][Event] removed deprecated methods | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | yes | Deprecations? | no | Fixed tickets | ~ | Tests pass? | yes | License | MIT Commits -------4ab3e8b
[3.0] [EventDispatcher][Event] removed deprecated name methods.ba70a48
[3.0] [EventDispatcher][Event] removed deprecated setDispatcher and getDispatcher methods.
This commit is contained in:
commit
9f195cd150
@ -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
|
||||
-----
|
||||
|
||||
|
@ -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 @@ 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.
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
}
|
||||
|
@ -43,9 +43,6 @@ class EventDispatcher implements EventDispatcherInterface
|
||||
$event = new Event();
|
||||
}
|
||||
|
||||
$event->setDispatcher($this);
|
||||
$event->setName($eventName);
|
||||
|
||||
if (!isset($this->listeners[$eventName])) {
|
||||
return $event;
|
||||
}
|
||||
|
@ -121,15 +121,6 @@ abstract class AbstractEventDispatcherTest extends \PHPUnit_Framework_TestCase
|
||||
$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 @@ 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();
|
||||
|
@ -164,9 +164,6 @@ class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
|
||||
$dispatcher = new ContainerAwareEventDispatcher($container);
|
||||
$dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
|
||||
|
||||
$event->setDispatcher($dispatcher);
|
||||
$event->setName('onEvent');
|
||||
|
||||
$service
|
||||
->expects($this->once())
|
||||
->method('onEvent')
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user