Skip to content
This repository
Browse code

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...
commit ddd30d0b8e9f89ed0515344f14dbe89094b0fbfe 2 parents 2675007 + cec98c1
Fabien Potencier fabpot authored
3  src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php
@@ -28,7 +28,6 @@
28 28 use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\FragmentRendererPass;
29 29 use Symfony\Component\DependencyInjection\ContainerBuilder;
30 30 use Symfony\Component\DependencyInjection\Compiler\PassConfig;
31   -use Symfony\Component\DependencyInjection\Scope;
32 31 use Symfony\Component\HttpFoundation\Request;
33 32 use Symfony\Component\HttpKernel\Bundle\Bundle;
34 33
@@ -54,8 +53,6 @@ public function build(ContainerBuilder $container)
54 53 {
55 54 parent::build($container);
56 55
57   - $container->addScope(new Scope('request'));
58   -
59 56 $container->addCompilerPass(new RoutingResolverPass());
60 57 $container->addCompilerPass(new ProfilerPass());
61 58 $container->addCompilerPass(new RegisterKernelListenersPass(), PassConfig::TYPE_AFTER_REMOVING);
4 src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php
@@ -72,8 +72,8 @@ public function process(ContainerBuilder $container)
72 72 $this->currentScopeChildren = array_keys($scopes);
73 73 $this->currentScopeAncestors = array();
74 74 } elseif (ContainerInterface::SCOPE_PROTOTYPE !== $scope) {
75   - $this->currentScopeChildren = $children[$scope];
76   - $this->currentScopeAncestors = $ancestors[$scope];
  75 + $this->currentScopeChildren = isset($children[$scope]) ? $children[$scope] : array();
  76 + $this->currentScopeAncestors = isset($ancestors[$scope]) ? $ancestors[$scope] : array();
77 77 }
78 78
79 79 $this->validateReferences($definition->getArguments());
4 src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php
@@ -18,9 +18,10 @@
18 18 use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
19 19 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
20 20 use Symfony\Component\DependencyInjection\ContainerInterface;
  21 +use Symfony\Component\DependencyInjection\Scope;
21 22
22 23 /**
23   - * This HttpKernel is used to manage scope changes of the DI container.
  24 + * Adds a managed request scope.
24 25 *
25 26 * @author Fabien Potencier <fabien@symfony.com>
26 27 * @author Johannes M. Schmitt <schmittjoh@gmail.com>
@@ -41,6 +42,7 @@ public function __construct(EventDispatcherInterface $dispatcher, ContainerInter
41 42 parent::__construct($dispatcher, $controllerResolver);
42 43
43 44 $this->container = $container;
  45 + $container->addScope(new Scope('request'));
44 46 }
45 47
46 48 /**

0 comments on commit ddd30d0

Please sign in to comment.
Something went wrong with that request. Please try again.