From 612dce873be0b2cd36aaeca04a602a7213d0453d Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 16 Jan 2011 08:53:28 +0100 Subject: [PATCH] [DependencyInjection] added the possibility to pass the type of compiler pass in ContainerBuilder::addCompilerPAss --- src/Symfony/Bundle/DoctrineBundle/DoctrineBundle.php | 5 ++--- .../Component/DependencyInjection/Compiler/Compiler.php | 5 +++-- .../Component/DependencyInjection/ContainerBuilder.php | 7 ++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Bundle/DoctrineBundle/DoctrineBundle.php b/src/Symfony/Bundle/DoctrineBundle/DoctrineBundle.php index aa38714bcc1b..f8aa6a8e3ae8 100644 --- a/src/Symfony/Bundle/DoctrineBundle/DoctrineBundle.php +++ b/src/Symfony/Bundle/DoctrineBundle/DoctrineBundle.php @@ -29,8 +29,7 @@ public function registerExtensions(ContainerBuilder $container) { parent::registerExtensions($container); - $passConfig = $container->getCompilerPassConfig(); - $passConfig->addPass(new RegisterEventListenersAndSubscribersPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION); - $passConfig->addPass(new CreateProxyDirectoryPass(), PassConfig::TYPE_BEFORE_REMOVING); + $container->addCompilerPass(new RegisterEventListenersAndSubscribersPass(), PassConfig::TYPE_BEFORE_OPTIMIZATION); + $container->addCompilerPass(new CreateProxyDirectoryPass(), PassConfig::TYPE_BEFORE_REMOVING); } } diff --git a/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php b/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php index ff6c48fd25e1..bf6d1bd95be3 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php @@ -3,6 +3,7 @@ namespace Symfony\Component\DependencyInjection\Compiler; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Compiler\PassConfig; /** * This class is used to remove circular dependencies between individual passes. @@ -34,9 +35,9 @@ public function getServiceReferenceGraph() return $this->serviceReferenceGraph; } - public function addPass(CompilerPassInterface $pass) + public function addPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION) { - $this->passConfig->addPass($pass); + $this->passConfig->addPass($pass, $type); } public function addLogMessage($string) diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 998a4e0d6523..c52769d641e3 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -4,6 +4,7 @@ use Symfony\Component\DependencyInjection\Compiler\Compiler; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\Extension\ExtensionInterface; use Symfony\Component\DependencyInjection\InterfaceInjector; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; @@ -148,11 +149,11 @@ public function loadFromExtension($extension, $tag, array $values = array()) * Adds a compiler pass at the end of the current passes * * @param CompilerPassInterface $pass - * @return void + * @param string $type */ - public function addCompilerPass(CompilerPassInterface $pass) + public function addCompilerPass(CompilerPassInterface $pass, $type = PassConfig::TYPE_BEFORE_OPTIMIZATION) { - $this->compiler->addPass($pass); + $this->compiler->addPass($pass, $type); $this->addObjectResource($pass); }