Skip to content

Commit ddd30d0

Browse files
committed
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
2 parents 2675007 + cec98c1 commit ddd30d0

File tree

3 files changed

+5
-6
lines changed

3 files changed

+5
-6
lines changed

src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\FragmentRendererPass;
2929
use Symfony\Component\DependencyInjection\ContainerBuilder;
3030
use Symfony\Component\DependencyInjection\Compiler\PassConfig;
31-
use Symfony\Component\DependencyInjection\Scope;
3231
use Symfony\Component\HttpFoundation\Request;
3332
use Symfony\Component\HttpKernel\Bundle\Bundle;
3433

@@ -54,8 +53,6 @@ public function build(ContainerBuilder $container)
5453
{
5554
parent::build($container);
5655

57-
$container->addScope(new Scope('request'));
58-
5956
$container->addCompilerPass(new RoutingResolverPass());
6057
$container->addCompilerPass(new ProfilerPass());
6158
$container->addCompilerPass(new RegisterKernelListenersPass(), PassConfig::TYPE_AFTER_REMOVING);

src/Symfony/Component/DependencyInjection/Compiler/CheckReferenceValidityPass.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ public function process(ContainerBuilder $container)
7272
$this->currentScopeChildren = array_keys($scopes);
7373
$this->currentScopeAncestors = array();
7474
} 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();
7777
}
7878

7979
$this->validateReferences($definition->getArguments());

src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@
1818
use Symfony\Component\HttpKernel\Controller\ControllerResolverInterface;
1919
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
2020
use Symfony\Component\DependencyInjection\ContainerInterface;
21+
use Symfony\Component\DependencyInjection\Scope;
2122

2223
/**
23-
* This HttpKernel is used to manage scope changes of the DI container.
24+
* Adds a managed request scope.
2425
*
2526
* @author Fabien Potencier <fabien@symfony.com>
2627
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
@@ -41,6 +42,7 @@ public function __construct(EventDispatcherInterface $dispatcher, ContainerInter
4142
parent::__construct($dispatcher, $controllerResolver);
4243

4344
$this->container = $container;
45+
$container->addScope(new Scope('request'));
4446
}
4547

4648
/**

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy