fixed request scope issues (refs #7457)

This commit is contained in:
Fabien Potencier 2013-05-09 09:53:36 +02:00
parent e9bd48e9b2
commit 853f681957
2 changed files with 10 additions and 1 deletions

View File

@ -28,6 +28,7 @@ use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\FragmentRenderer
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\SerializerPass;
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;
use Symfony\Component\HttpKernel\DependencyInjection\RegisterListenersPass;
@ -54,6 +55,10 @@ class FrameworkBundle extends Bundle
{
parent::build($container);
// we need to add the request scope as early as possible so that
// the compilation can find scope widening issues
$container->addScope(new Scope('request'));
$container->addCompilerPass(new RoutingResolverPass());
$container->addCompilerPass(new ProfilerPass());
$container->addCompilerPass(new RegisterListenersPass(), PassConfig::TYPE_AFTER_REMOVING);

View File

@ -42,7 +42,11 @@ class ContainerAwareHttpKernel extends HttpKernel
parent::__construct($dispatcher, $controllerResolver);
$this->container = $container;
$container->addScope(new Scope('request'));
// the request scope might have been created before (see FrameworkBundle)
if (!$container->hasScope('request')) {
$container->addScope(new Scope('request'));
}
}
/**