10000 [SecurityBundle] Avoid container injection in FirewallMap · symfony/symfony@9718a65 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9718a65

Browse files
committed
[SecurityBundle] Avoid container injection in FirewallMap
1 parent bbaea98 commit 9718a65

File tree

7 files changed

+8
-13
lines changed

7 files changed

+8
-13
lines changed

src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1717
use Symfony\Component\DependencyInjection\Alias;
1818
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
19+
use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
1920
use Symfony\Component\DependencyInjection\ChildDefinition;
2021
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
2122
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
@@ -239,7 +240,7 @@ private function createFirewalls($config, ContainerBuilder $container)
239240

240241
// load firewall map
241242
$mapDef = $container->getDefinition('security.firewall.map');
242-
$map = $authenticationProviders = array();
243+
$map = $authenticationProviders = $contextRefs = array();
243244
foreach ($firewalls as $name => $firewall) {
244245
$configId = 'security.firewall.map.config.'.$name;
245246

@@ -253,8 +254,10 @@ private function createFirewalls($config, ContainerBuilder $container)
253254
->replaceArgument(2, new Reference($configId))
254255
;
255256

257+
$contextRefs[$contextId] = new Reference($contextId);
256258
$map[$contextId] = $matcher;
257259
}
260+
$mapDef->replaceArgument(0, new ServiceLocatorArgument($contextRefs));
258261
$mapDef->replaceArgument(1, new IteratorArgument($map));
259262

260263
// add authentication providers to authentication manager

src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@
105105
</service>
106106

107107
<service id="security.firewall.map" class="Symfony\Bundle\SecurityBundle\Security\FirewallMap" public="false">
108-
<argument type="service" id="service_container" />
109-
<argument />
108+
<argument /> <!-- Firewall context locator -->
109+
<argument /> <!-- Request matchers -->
110110
</service>
111111

112112
<service id="security.firewall.context" class="Symfony\Bundle\SecurityBundle\Security\FirewallContext" abstract="true">

src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
namespace Symfony\Bundle\SecurityBundle\Security;
1313

14+
use Psr\Container\ContainerInterface;
1415
use Symfony\Component\Security\Http\FirewallMapInterface;
1516
use Symfony\Component\HttpFoundation\Request;
16-
use Symfony\Component\DependencyInjection\ContainerInterface;
1717

1818
/**
1919
* This is a lazy-loading firewall map implementation.
@@ -116,9 +116,6 @@ public function __construct(ContainerInterface $container, $map)
116116
$this->contexts = new \SplObjectStorage();
117117
}
118118

119-
/**
120-
* {@inheritdoc}
121-
*/
122119
public function getListeners(Request $request)
123120
{
124121
$context = $this->getFirewallContext($request);

src/Symfony/Component/DependencyInjection/Argument/ServiceLocatorArgument.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Argument;
1313

14-
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
15-
1614
/**
1715
* Represents a service locator able to lazy load a given range of services.
1816
*

src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\DependencyInjection\Loader;
1313

14-
use Symfony\Component\Config\Resource\FileResource;
1514
use Symfony\Component\Config\Util\XmlUtils;
1615
use Symfony\Component\DependencyInjection\ContainerInterface;
1716
use Symfony\Component\DependencyInjection\Alias;

src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
use Symfony\Component\DependencyInjection\Reference;
2222
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
2323
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
24-
use Symfony\Component\Config\Resource\FileResource;
2524
use Symfony\Component\Yaml\Exception\ParseException;
2625
use Symfony\Component\Yaml\Parser as YamlParser;
2726
use Symfony\Component\Yaml\Tag\TaggedValue;

src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
use Symfony\Component\DependencyInjection\Reference;
2323
use Symfony\Component\DependencyInjection\Definition;
2424
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
25-
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
2625
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
2726
use Symfony\Component\DependencyInjection\ServiceLocator;
2827
use Symfony\Component\DependencyInjection\Variable;
@@ -522,7 +521,7 @@ public function testServiceLocatorArgumentProvideServiceLocator()
522521
$dump = $dumper->dump(array('class' => 'Symfony_DI_PhpDumper_Test_Locator_Argument_Provide_Service_Locator'));
523522
$this->assertStringEqualsFile(self::$fixturesPath.'/php/services_locator_argument.php', $dump);
524523

525-
require_once(self::$fixturesPath.'/php/services_locator_argument.php');
524+
require_once self::$fixturesPath.'/php/services_locator_argument.php';
526525

527526
$container = new \Symfony_DI_PhpDumper_Test_Locator_Argument_Provide_Service_Locator();
528527
$lazyContext = $container->get('lazy_context');

0 commit comments

Comments
 (0)
0