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 339c653

Browse filesBrowse files
bug #22814 [FrameworkBundle] FC with EventDispatcher 4.0 (xabbuh)
This PR was merged into the 4.0-dev branch. Discussion ---------- [FrameworkBundle] FC with EventDispatcher 4.0 | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #22796 (comment) | License | MIT | Doc PR | Commits ------- b7c76f7 [FrameworkBundle] FC with EventDispatcher 4.0
2 parents da61abd + b7c76f7 commit 339c653
Copy full SHA for 339c653

File tree

2 files changed

+16
-1
lines changed
Filter options

2 files changed

+16
-1
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
3333
use Symfony\Component\DependencyInjection\Reference;
3434
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
35+
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
36+
use Symfony\Component\EventDispatcher\EventDispatcher;
3537
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
3638
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
3739
use Symfony\Component\Finder\Finder;
@@ -94,6 +96,13 @@ public function load(array $configs, ContainerBuilder $container)
9496
$loader->load('web.xml');
9597
$loader->load('services.xml');
9698

99+
// forward compatibility with Symfony 4.0 where the ContainerAwareEventDispatcher class is removed
100+
if (!class_exists(ContainerAwareEventDispatcher::class)) {
101+
$definition = $container->getDefinition('event_dispatcher');
102+
$definition->setClass(EventDispatcher::class);
103+
$definition->setArguments(array());
104+
}
105+
97106
if (PHP_VERSION_ID < 70000) {
98107
$definition = $container->getDefinition('kernel.class_cache.cache_warmer');
99108
$definition->addTag('kernel.cache_warmer');

‎src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Doctrine\Common\Annotations\AnnotationReader;
1515
use Doctrine\Common\Annotations\CachedReader;
1616
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
17+
use Symfony\Component\EventDispatcher\EventDispatcher;
1718
use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface;
1819
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher;
1920
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
@@ -55,7 +56,12 @@ public function testEventDispatcherAutowiring()
5556
$container = static::$kernel->getContainer();
5657

5758
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
58-
$this->assertInstanceOf(ContainerAwareEventDispatcher::class, $autowiredServices->getDispatcher(), 'The event_dispatcher service should be injected if the debug is not enabled');
59+
60+
if (class_exists(ContainerAwareEventDispatcher::class)) {
61+
$this->assertInstanceOf(ContainerAwareEventDispatcher::class, $autowiredServices->getDispatcher(), 'The event_dispatcher service should be injected if the debug is not enabled');
62+
} else {
63+
$this->assertInstanceOf(EventDispatcher::class, $autowiredServices->getDispatcher(), 'The event_dispatcher service should be injected if the debug is not enabled');
64+
}
5965

6066
static::bootKernel(array('debug' => true));
6167
$container = static::$kernel->getContainer();

0 commit comments

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