Permalink
Browse files

merged branch fabpot/request-scope (PR #7457)

This PR was merged into the master branch.

Discussion
----------

moved the request scope creation to the ContainerAwareHttpKernel class

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | symfony/symfony-docs#2343

While updating the scope documentation, I realized that the request scope was created in the FrameworkBundle while the HttpKernel that manages it was in the HttpKernel component. So, this PR makes things more consistent.

Commits
-------

cec98c1 [DependencyInjection] fixed PHP notice when the scope is not defined
550df5a moved the request scope creation to the ContainerAwareHttpKernel class
  • Loading branch information...
2 parents 2675007 + cec98c1 commit ddd30d0b8e9f89ed0515344f14dbe89094b0fbfe @fabpot fabpot committed Mar 23, 2013
View
3 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;
@@ -54,8 +53,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);
View
4 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());
View
4 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 <fabien@symfony.com>
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
@@ -41,6 +42,7 @@ public function __construct(EventDispatcherInterface $dispatcher, ContainerInter
parent::__construct($dispatcher, $controllerResolver);
$this->container = $container;
+ $container->addScope(new Scope('request'));
}
/**

0 comments on commit ddd30d0

Please sign in to comment.