From 550df5a85a64de2c3596fede6225d338c9ab79aa Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 23 Mar 2013 10:14:37 +0100 Subject: [PATCH 1/2] moved the request scope creation to the ContainerAwareHttpKernel class --- src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php | 3 --- .../DependencyInjection/ContainerAwareHttpKernel.php | 4 +++- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php index 5523499db5008..6879626d010af 100644 --- a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php +++ b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php @@ -28,7 +28,6 @@ use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\FragmentRendererPass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\PassConfig; -use Symfony\Component\DependencyInjection\Scope; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -56,8 +55,6 @@ public function build(ContainerBuilder $container) { parent::build($container); - $container->addScope(new Scope('request')); - $container->addCompilerPass(new RoutingResolverPass()); $container->addCompilerPass(new ProfilerPass()); $container->addCompilerPass(new RegisterKernelListenersPass(), PassConfig::TYPE_AFTER_REMOVING); diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php b/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php index 20b4a5e75e9ad..9487667c8ab10 100644 --- a/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php +++ b/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php @@ -18,9 +18,10 @@ use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\DependencyInjection\Scope; /** - * This HttpKernel is used to manage scope changes of the DI container. + * Adds a managed request scope. * * @author Fabien Potencier * @author Johannes M. Schmitt @@ -41,6 +42,7 @@ public function __construct(EventDispatcherInterface $dispatcher, ContainerInter parent::__construct($dispatcher, $controllerResolver); $this->container = $container; + $container->addScope(new Scope('request')); } /** From cec98c1d7a07da9d7d72e4984f5ae584db4aed0e Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 23 Mar 2013 11:39:42 +0100 Subject: [PATCH 2/2] [DependencyInjection] fixed PHP notice when the scope is not defined --- .../Compiler/CheckReferenceValidityPass.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php index 436dc74adbf13..9351b11b39dcf 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php @@ -72,8 +72,8 @@ public function process(ContainerBuilder $container) $this->currentScopeChildren = array_keys($scopes); $this->currentScopeAncestors = array(); } elseif (ContainerInterface::SCOPE_PROTOTYPE !== $scope) { - $this->currentScopeChildren = $children[$scope]; - $this->currentScopeAncestors = $ancestors[$scope]; + $this->currentScopeChildren = isset($children[$scope]) ? $children[$scope] : array(); + $this->currentScopeAncestors = isset($ancestors[$scope]) ? $ancestors[$scope] : array(); } $this->validateReferences($definition->getArguments());