8000 [3.0][EventDispatcher][Event] removed deprecated methods by aitboudad · Pull Request #13260 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[3.0][EventDispatcher][Event] removed deprecated methods #13260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Symfony/Component/EventDispatcher/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
-----

Expand Down
10000
70 changes: 0 additions & 70 deletions src/Symfony/Component/EventDispatcher/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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;
}
}
3 changes: 0 additions & 3 deletions src/Symfony/Component/EventDispatcher/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
D856
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
33 changes: 0 additions & 33 deletions src/Symfony/Component/EventDispatcher/Tests/EventTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,13 @@ 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.
*/
protected function setUp()
{
$this->event = new Event();
$this->dispatcher = new EventDispatcher();
}

/**
Expand All @@ -46,7 +40,6 @@ protected function setUp()
protected function tearDown()
{
$this->event = null;
$this->dispatcher = null;
}

public function testIsPropagationStopped()
Expand All @@ -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());
}
}
0