[FrameworkBundle] FC with EventDispatcher 4.0
This commit is contained in:
parent
e9e19e7f4d
commit
b7c76f7147
@ -32,6 +32,8 @@ use Symfony\Component\DependencyInjection\Exception\LogicException;
|
||||
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
|
||||
use Symfony\Component\DependencyInjection\Reference;
|
||||
use Symfony\Component\DependencyInjection\ServiceSubscriberInterface;
|
||||
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
|
||||
use Symfony\Component\Finder\Finder;
|
||||
@ -94,6 +96,13 @@ class FrameworkExtension extends Extension
|
||||
$loader->load('web.xml');
|
||||
$loader->load('services.xml');
|
||||
|
||||
// forward compatibility with Symfony 4.0 where the ContainerAwareEventDispatcher class is removed
|
||||
if (!class_exists(ContainerAwareEventDispatcher::class)) {
|
||||
$definition = $container->getDefinition('event_dispatcher');
|
||||
$definition->setClass(EventDispatcher::class);
|
||||
$definition->setArguments(array());
|
||||
}
|
||||
|
||||
if (PHP_VERSION_ID < 70000) {
|
||||
$definition = $container->getDefinition('kernel.class_cache.cache_warmer');
|
||||
$definition->addTag('kernel.cache_warmer');
|
||||
|
@ -14,6 +14,7 @@ namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;
|
||||
use Doctrine\Common\Annotations\AnnotationReader;
|
||||
use Doctrine\Common\Annotations\CachedReader;
|
||||
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcher;
|
||||
use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface;
|
||||
use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher;
|
||||
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
|
||||
@ -55,7 +56,12 @@ class AutowiringTypesTest extends WebTestCase
|
||||
$container = static::$kernel->getContainer();
|
||||
|
||||
$autowiredServices = $container->get('test.autowiring_types.autowired_services');
|
||||
$this->assertInstanceOf(ContainerAwareEventDispatcher::class, $autowiredServices->getDispatcher(), 'The event_dispatcher service should be injected if the debug is not enabled');
|
||||
|
||||
if (class_exists(ContainerAwareEventDispatcher::class)) {
|
||||
$this->assertInstanceOf(ContainerAwareEventDispatcher::class, $autowiredServices->getDispatcher(), 'The event_dispatcher service should be injected if the debug is not enabled');
|
||||
} else {
|
||||
$this->assertInstanceOf(EventDispatcher::class, $autowiredServices->getDispatcher(), 'The event_dispatcher service should be injected if the debug is not enabled');
|
||||
}
|
||||
|
||||
static::bootKernel(array('debug' => true));
|
||||
$container = static::$kernel->getContainer();
|
||||
|
Reference in New Issue
Block a user