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 c4a6a8a

Browse filesBrowse files
[EventDispatcher] Deprecate ContainerAwareEventDispatcher
1 parent 8725f69 commit c4a6a8a
Copy full SHA for c4a6a8a

File tree

5 files changed

+36
-0
lines changed
Filter options

5 files changed

+36
-0
lines changed

‎UPGRADE-3.3.md

Copy file name to clipboardExpand all lines: UPGRADE-3.3.md
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ DependencyInjection
1616
* The `DefinitionDecorator` class is deprecated and will be removed in 4.0, use
1717
the `ChildDefinition` class instead.
1818

19+
EventDispatcher
20+
---------------
21+
22+
* The `ContainerAwareEventDispatcher` class has been deprecated.
23+
Use `EventDispatcher` with closure-proxy injection instead.
24+
1925
Finder
2026
------
2127

‎UPGRADE-4.0.md

Copy file name to clipboardExpand all lines: UPGRADE-4.0.md
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,12 @@ DependencyInjection
4242
* Requesting a private service with the `Container::get()` method is no longer
4343
supported.
4444

45+
EventDispatcher
46+
---------------
47+
48+
* The `ContainerAwareEventDispatcher` class has been removed.
49+
Use `EventDispatcher` with closure-proxy injection instead.
50+
4551
ExpressionLanguage
4652
----------
4753

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

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

4+
3.3.0
5+
-----
6+
7+
* The ContainerAwareEventDispatcher class has been deprecated. Use EventDispatcher with closure-proxy injection instead.
8+
49
3.0.0
510
-----
611

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php
+16Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
* @author Fabien Potencier <fabien@symfony.com>
2121
* @author Bernhard Schussek <bschussek@gmail.com>
2222
* @author Jordan Alliot <jordan.alliot@gmail.com>
23+
*
24+
* @deprecated since 3.3, to be removed in 4.0. Use EventDispatcher with closure-proxy injection instead.
2325
*/
2426
class ContainerAwareEventDispatcher extends EventDispatcher
2527
{
@@ -52,6 +54,14 @@ class ContainerAwareEventDispatcher extends EventDispatcher
5254
public function __construct(ContainerInterface $container)
5355
{
5456
$this->container = $container;
57+
58+
$class = get_class($this);
59+
if ($this instanceof \PHPUnit_Framework_MockObject_MockObject || $this instanceof \Prophecy\Doubler\DoubleInterface) {
60+
$class = get_parent_class($class);
61+
}
62+
if (__CLASS__ !== $class) {
63+
@trigger_error(sprintf('The %s class is deprecated since version 3.3 and will be removed in 4.0. Use EventDispatcher with closure-proxy injection instead.', __CLASS__), E_USER_DEPRECATED);
64+
}
5565
}
5666

5767
/**
@@ -68,6 +78,8 @@ public function __construct(ContainerInterface $container)
6878
*/
6979
public function addListenerService($eventName, $callback, $priority = 0)
7080
{
81+
@trigger_error(sprintf('The %s class is deprecated since version 3.3 and will be removed in 4.0. Use EventDispatcher with closure-proxy injection instead.', __CLASS__), E_USER_DEPRECATED);
82+
7183
if (!is_array($callback) || 2 !== count($callback)) {
7284
throw new \InvalidArgumentException('Expected an array("service", "method") argument');
7385
}
@@ -148,6 +160,8 @@ public function getListenerPriority($eventName, $listener)
148160
*/
149161
public function addSubscriberService($serviceId, $class)
150162
{
163+
@trigger_error(sprintf('The %s class is deprecated since version 3.3 and will be removed in 4.0. Use EventDispatcher with closure-proxy injection instead.', __CLASS__), E_USER_DEPRECATED);
164+
151165
foreach ($class::getSubscribedEvents() as $eventName => $params) {
152166
if (is_string($params)) {
153167
$this->listenerIds[$eventName][] = array($serviceId, $params, 0);
@@ -163,6 +177,8 @@ public function addSubscriberService($serviceId, $class)
163177

164178
public function getContainer()
165179
{
180+
@trigger_error('The '.__METHOD__.'() method is deprecated since version 3.3 as its class will be removed in 4.0. Inject the container or the services you need in your listeners/subscribers instead.', E_USER_DEPRECATED);
181+
166182
return $this->container;
167183
}
168184

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
use Symfony\Component\EventDispatcher\Event;
1717
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
1818

19+
/**
20+
* @group legacy
21+
*/
1922
class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest
2023
{
2124
protected function createEventDispatcher()

0 commit comments

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