Merge branch '2.2' into 2.3

* 2.2:
  Revert "merged branch fabpot/event-dispatcher-debug (PR #9068)"

Conflicts:
	src/Symfony/Component/HttpKernel/DependencyInjection/RegisterListenersPass.php
	src/Symfony/Component/HttpKernel/Tests/DependencyInjection/RegisterListenersPassTest.php
This commit is contained in:
Fabien Potencier 2013-09-23 17:56:30 +02:00
commit c60a8e962b
4 changed files with 9 additions and 14 deletions

View File

@ -53,14 +53,12 @@ class FrameworkExtension extends Extension
if ($container->getParameter('kernel.debug')) { if ($container->getParameter('kernel.debug')) {
$loader->load('debug.xml'); $loader->load('debug.xml');
// only HttpKernel needs the debug event dispatcher
$definition = $container->findDefinition('http_kernel'); $definition = $container->findDefinition('http_kernel');
$definition->replaceArgument(2, new Reference('debug.controller_resolver')); $arguments = $definition->getArguments();
$arguments[0] = new Reference('debug.event_dispatcher');
// replace the regular event_dispatcher service with the debug one $arguments[2] = new Reference('debug.controller_resolver');
$definition = $container->findDefinition('event_dispatcher'); $definition->setArguments($arguments);
$definition->setPublic(false);
$container->setDefinition('debug.event_dispatcher.parent', $definition);
$container->setAlias('event_dispatcher', 'debug.event_dispatcher');
} }
$configuration = $this->getConfiguration($configs, $container); $configuration = $this->getConfiguration($configs, $container);

View File

@ -16,7 +16,7 @@
<service id="debug.event_dispatcher" class="%debug.event_dispatcher.class%"> <service id="debug.event_dispatcher" class="%debug.event_dispatcher.class%">
<tag name="monolog.logger" channel="event" /> <tag name="monolog.logger" channel="event" />
<argument type="service" id="debug.event_dispatcher.parent" /> <argument type="service" id="event_dispatcher" />
<argument type="service" id="debug.stopwatch" /> <argument type="service" id="debug.stopwatch" />
<argument type="service" id="logger" on-invalid="null" /> <argument type="service" id="logger" on-invalid="null" />
<call method="setProfiler"><argument type="service" id="profiler" on-invalid="null" /></call> <call method="setProfiler"><argument type="service" id="profiler" on-invalid="null" /></call>

View File

@ -50,11 +50,11 @@ class RegisterListenersPass implements CompilerPassInterface
public function process(ContainerBuilder $container) public function process(ContainerBuilder $container)
{ {
if (!$container->hasDefinition($this->dispatcherService) && !$container->hasAlias($this->dispatcherService)) { if (!$container->hasDefinition($this->dispatcherService)) {
return; return;
} }
$definition = $container->findDefinition($this->dispatcherService); $definition = $container->getDefinition($this->dispatcherService);
foreach ($container->findTaggedServiceIds($this->listenerTag) as $id => $events) { foreach ($container->findTaggedServiceIds($this->listenerTag) as $id => $events) {
$def = $container->getDefinition($id); $def = $container->getDefinition($id);

View File

@ -84,11 +84,8 @@ class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase
->method('getDefinition') ->method('getDefinition')
->will($this->returnValue($definition)); ->will($this->returnValue($definition));
$builder->expects($this->atLeastOnce())
->method('findDefinition')
->will($this->returnValue($definition));
$registerListenersPass = new RegisterListenersPass(); $registerListenersPass = new RegisterListenersPass();
$registerListenersPass->process($builder); $registerListenersPass->process($builder);
} }