diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php index 61a7d7a9170d..68aad4a6a74c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php @@ -479,12 +479,6 @@ private function registerDebugConfiguration(array $config, ContainerBuilder $con if ($debug) { $loader->load('debug.xml'); - - // replace the regular event_dispatcher service with the debug one - $definition = $container->findDefinition('event_dispatcher'); - $definition->setPublic(false); - $container->setDefinition('debug.event_dispatcher.parent', $definition); - $container->setAlias('event_dispatcher', 'debug.event_dispatcher'); } $definition = $container->findDefinition('debug.debug_handlers_listener'); diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml index 073851b038e6..3d260e4aff72 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml @@ -9,9 +9,9 @@ - + - + diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml index dbc830e60aa3..6f566c80b513 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml @@ -7,6 +7,8 @@ + Symfony\Component\EventDispatcher\EventDispatcherInterface + Symfony\Component\EventDispatcher\EventDispatcher diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php index 52b8c8cdcf52..5fcf207e98ba 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/AutowiringTypesTest.php @@ -14,6 +14,8 @@ use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Annotations\CachedReader; use Symfony\Component\Templating\EngineInterface as ComponentEngineInterface; +use Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher; +use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher; use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface; class AutowiringTypesTest extends WebTestCase @@ -46,6 +48,21 @@ public function testTemplatingAutowiring() $this->assertInstanceOf(ComponentEngineInterface::class, $autowiredServices->getEngine()); } + public function testEventDispatcherAutowiring() + { + static::bootKernel(array('debug' => false)); + $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'); + + static::bootKernel(array('debug' => true)); + $container = static::$kernel->getContainer(); + + $autowiredServices = $container->get('test.autowiring_types.autowired_services'); + $this->assertInstanceOf(TraceableEventDispatcher::class, $autowiredServices->getDispatcher(), 'The debug.event_dispatcher service should be injected if the debug is enabled'); + } + protected static function createKernel(array $options = array()) { return parent::createKernel(array('test_case' => 'AutowiringTypes') + $options); diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php index 0636d591e567..9f9faf29f3cc 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Functional/Bundle/TestBundle/AutowiringTypes/AutowiredServices.php @@ -14,18 +14,21 @@ use Doctrine\Common\Annotations\Reader; use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface as FrameworkBundleEngineInterface; use Symfony\Component\Templating\EngineInterface; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; class AutowiredServices { private $annotationReader; private $frameworkBundleEngine; private $engine; + private $dispatcher; - public function __construct(Reader $annotationReader = null, FrameworkBundleEngineInterface $frameworkBundleEngine, EngineInterface $engine) + public function __construct(Reader $annotationReader = null, FrameworkBundleEngineInterface $frameworkBundleEngine, EngineInterface $engine, EventDispatcherInterface $dispatcher) { $this->annotationReader = $annotationReader; $this->frameworkBundleEngine = $frameworkBundleEngine; $this->engine = $engine; + $this->dispatcher = $dispatcher; } public function getAnnotationReader() @@ -42,4 +45,9 @@ public function getEngine() { return $this->engine; } + + public function getDispatcher() + { + return $this->dispatcher; + } }