diff --git a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php index 4b84ab1139..69c896d4f9 100644 --- a/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php +++ b/src/Symfony/Bundle/DoctrineBundle/Tests/DependencyInjection/AbstractDoctrineExtensionTest.php @@ -439,7 +439,7 @@ abstract class AbstractDoctrineExtensionTest extends TestCase new Reference('doctrine.orm.default_annotation_metadata_driver'), 'DoctrineBundle\Tests\DependencyInjection\Fixtures\Bundles\XmlBundle\Entity' )); - + $configDef = $container->getDefinition('doctrine.orm.default_configuration'); $this->assertDICDefinitionMethodCallOnce($configDef, 'setAutoGenerateProxyClasses', array(false)); } @@ -505,12 +505,13 @@ abstract class AbstractDoctrineExtensionTest extends TestCase public function testSingleEntityManagerMultipleMappingBundleDefinitions() { $container = $this->getContainer(array('YamlBundle', 'AnnotationsBundle', 'XmlBundle')); - + $loader = new DoctrineExtension(); $container->registerExtension($loader); $this->loadFromFile($container, 'orm_single_em_bundle_mappings'); + $container->getCompilerPassConfig()->setRemovingPasses(array()); $container->freeze(); $definition = $container->getDefinition('doctrine.orm.default_metadata_driver'); @@ -556,6 +557,7 @@ abstract class AbstractDoctrineExtensionTest extends TestCase $this->loadFromFile($container, 'orm_multiple_em_bundle_mappings'); + $container->getCompilerPassConfig()->setRemovingPasses(array()); $container->freeze(); $def1 = $container->getDefinition('doctrine.orm.em1_metadata_driver'); @@ -628,7 +630,7 @@ abstract class AbstractDoctrineExtensionTest extends TestCase /** * Assertion on the Class of a DIC Service Definition. - * + * * @param \Symfony\Component\DependencyInjection\Definition $definition * @param string $expectedClass */ diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConstraintValidatorsPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConstraintValidatorsPass.php new file mode 100644 index 0000000000..11c8b076f8 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddConstraintValidatorsPass.php @@ -0,0 +1,28 @@ +hasDefinition('validator.validator_factory')) { + return; + } + + $validators = array(); + foreach ($container->findTaggedServiceIds('validator.constraint_validator') as $id => $attributes) { + if (isset($attributes[0]['alias'])) { + $validators[$attributes[0]['alias']] = $id; + } + } + + $definition = $container->getDefinition('validator.validator_factory'); + $arguments = $definition->getArguments(); + $arguments[1] = $validators; + $definition->setArguments($arguments); + } +} \ No newline at end of file diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddTemplatingRenderersPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddTemplatingRenderersPass.php new file mode 100644 index 0000000000..3dda3fcce8 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddTemplatingRenderersPass.php @@ -0,0 +1,41 @@ +hasDefinition('templating.engine')) { + return; + } + + $renderers = array(); + foreach ($container->findTaggedServiceIds('templating.renderer') as $id => $attributes) { + if (isset($attributes[0]['alias'])) { + $renderers[$attributes[0]['alias']] = new Reference($id); + $container->getDefinition($id)->addMethodCall('setEngine', array(new Reference('templating.engine'))); + } + } + + $helpers = array(); + foreach ($container->findTaggedServiceIds('templating.helper') as $id => $attributes) { + if (isset($attributes[0]['alias'])) { + $helpers[$attributes[0]['alias']] = $id; + } + } + + $definition = $container->getDefinition('templating.engine'); + $arguments = $definition->getArguments(); + $arguments[2] = $renderers; + $definition->setArguments($arguments); + + if (count($helpers) > 0) { + $definition->addMethodCall('setHelpers', array($helpers)); + } + } +} \ No newline at end of file diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/RegisterKernelListenersPass.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/RegisterKernelListenersPass.php new file mode 100644 index 0000000000..5aca068bd1 --- /dev/null +++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/RegisterKernelListenersPass.php @@ -0,0 +1,33 @@ +hasDefinition('event_dispatcher')) { + return; + } + + $listeners = array(); + foreach ($container->findTaggedServiceIds('kernel.listener') as $id => $attributes) { + $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; + + if (!isset($listeners[$priority])) { + $listeners[$priority] = array(); + } + + $listeners[$priority][] = new Reference($id); + } + + $container + ->getDefinition('event_dispatcher') + ->addMethodCall('registerKernelListeners', array($listeners)) + ; + } +} \ No newline at end of file diff --git a/src/Symfony/Bundle/FrameworkBundle/EventDispatcher.php b/src/Symfony/Bundle/FrameworkBundle/EventDispatcher.php index 057eddcbff..68ce00ea10 100644 --- a/src/Symfony/Bundle/FrameworkBundle/EventDispatcher.php +++ b/src/Symfony/Bundle/FrameworkBundle/EventDispatcher.php @@ -3,7 +3,6 @@ namespace Symfony\Bundle\FrameworkBundle; use Symfony\Component\EventDispatcher\EventDispatcher as BaseEventDispatcher; -use Symfony\Component\DependencyInjection\ContainerInterface; /* * This file is part of the Symfony package. @@ -15,18 +14,18 @@ use Symfony\Component\DependencyInjection\ContainerInterface; */ /** - * This EventDispatcher implementation uses a DependencyInjection container to load listeners. + * This EventDispatcher automatically gets the kernel listeners injected * * @author Fabien Potencier */ class EventDispatcher extends BaseEventDispatcher { - public function setContainer(ContainerInterface $container) + public function registerKernelListeners(array $kernelListeners) { - foreach ($container->findTaggedServiceIds('kernel.listener') as $id => $attributes) { - $priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; - - $container->get($id)->register($this, $priority); + foreach ($kernelListeners as $priority => $listeners) { + foreach ($listeners as $listener) { + $listener->register($this, $priority); + } } } } diff --git a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php index d4ed626c94..f7c878c6e2 100644 --- a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php +++ b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php @@ -2,6 +2,8 @@ namespace Symfony\Bundle\FrameworkBundle; +use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddTemplatingRenderersPass; +use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RegisterKernelListenersPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddSecurityVotersPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\ConverterManagerPass; use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RoutingResolverPass; @@ -60,5 +62,7 @@ class FrameworkBundle extends Bundle $container->addCompilerPass(new ConverterManagerPass()); $container->addCompilerPass(new RoutingResolverPass()); $container->addCompilerPass(new ProfilerPass()); + $container->addCompilerPass(new RegisterKernelListenersPass()); + $container->addCompilerPass(new AddTemplatingRenderersPass()); } } diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml index 181aa8e667..7b9c281d45 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/debug.xml @@ -11,9 +11,6 @@ - - - diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml index 5ef0c06816..371ba0f4a4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml @@ -14,12 +14,9 @@ - - - - + %error_handler.level% diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml index d3ffac6708..693f599a96 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/validator.xml @@ -27,18 +27,15 @@ -