Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbb455aa

Browse files
committed
[SecurityBundle] Avoid container injection in FirewallMap
1 parentbbaea98 commitbb455aa

File tree

11 files changed

+12
-21
lines changed

11 files changed

+12
-21
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
useSymfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1717
useSymfony\Component\DependencyInjection\Alias;
1818
useSymfony\Component\DependencyInjection\Argument\IteratorArgument;
19+
useSymfony\Component\DependencyInjection\Argument\ServiceLocatorArgument;
1920
useSymfony\Component\DependencyInjection\ChildDefinition;
2021
useSymfony\Component\HttpKernel\DependencyInjection\Extension;
2122
useSymfony\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 ($firewallsas$name =>$firewall) {
244245
$configId ='security.firewall.map.config.'.$name;
245246

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

257+
$contextRefs[$contextId] =newReference($contextId);
256258
$map[$contextId] =$matcher;
257259
}
260+
$mapDef->replaceArgument(0,newServiceLocatorArgument($contextRefs));
258261
$mapDef->replaceArgument(1,newIteratorArgument($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
<serviceid="security.firewall.map"class="Symfony\Bundle\SecurityBundle\Security\FirewallMap"public="false">
108-
<argumenttype="service"id="service_container" />
109-
<argument />
108+
<argument/><!-- Firewall context locator-->
109+
<argument /><!-- Request matchers-->
110110
</service>
111111

112112
<serviceid="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
namespaceSymfony\Bundle\SecurityBundle\Security;
1313

14+
usePsr\Container\ContainerInterface;
1415
useSymfony\Component\Security\Http\FirewallMapInterface;
1516
useSymfony\Component\HttpFoundation\Request;
16-
useSymfony\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
publicfunctiongetListeners(Request$request)
123120
{
124121
$context =$this->getFirewallContext($request);

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespaceSymfony\Component\DependencyInjection\Argument;
1313

14-
useSymfony\Component\DependencyInjection\Exception\InvalidArgumentException;
15-
1614
/**
1715
* Represents a service locator able to lazy load a given range of services.
1816
*
@@ -25,7 +23,7 @@ class ServiceLocatorArgument implements ArgumentInterface
2523
private$values;
2624

2725
/**
28-
* @param array $values An array ofmixed entries indexed by identifier
26+
* @param array $values An array ofreferences entries indexed by identifier
2927
*/
3028
publicfunction__construct(array$values)
3129
{

‎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
namespaceSymfony\Component\DependencyInjection\Loader;
1313

14-
useSymfony\Component\Config\Resource\FileResource;
1514
useSymfony\Component\Config\Util\XmlUtils;
1615
useSymfony\Component\DependencyInjection\ContainerInterface;
1716
useSymfony\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
useSymfony\Component\DependencyInjection\Reference;
2222
useSymfony\Component\DependencyInjection\Exception\InvalidArgumentException;
2323
useSymfony\Component\DependencyInjection\Exception\RuntimeException;
24-
useSymfony\Component\Config\Resource\FileResource;
2524
useSymfony\Component\Yaml\Exception\ParseException;
2625
useSymfony\Component\Yaml\ParserasYamlParser;
2726
useSymfony\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
useSymfony\Component\DependencyInjection\Reference;
2323
useSymfony\Component\DependencyInjection\Definition;
2424
useSymfony\Component\DependencyInjection\Exception\RuntimeException;
25-
useSymfony\Component\DependencyInjection\Exception\InvalidArgumentException;
2625
useSymfony\Component\DependencyInjection\Loader\YamlFileLoader;
2726
useSymfony\Component\DependencyInjection\ServiceLocator;
2827
useSymfony\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_onceself::$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');

‎src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_locator_argument.xml‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
<argumenttype="service-locator">
1414
<argumentkey="foo_baz"type="service"id="foo.baz"/>
1515
<argumentkey="container"type="service"id="service_container"/>
16-
<argumentkey="foo_string">foo</argument>
17-
<argumentkey="foo_collection"type="collection">
18-
<argument>foo</argument>
19-
</argument>
2016
</argument>
2117
</service>
2218
<serviceid="lazy_context_ignore_invalid_ref"class="LazyContext">

‎src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_locator_argument.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ services:
99
configurator:['%baz_class%', configureStatic1]
1010
lazy_context:
1111
class:LazyContext
12-
arguments:[!service_locator {foo_baz: '@foo.baz', container: '@service_container', foo_string: 'foo' , foo_collection: ['foo']} ]
12+
arguments:[!service_locator {foo_baz: '@foo.baz', container: '@service_container'} ]
1313
lazy_context_ignore_invalid_ref:
1414
class:LazyContext
1515
arguments:[!service_locator {foo_baz: '@foo.baz', invalid: '@?invalid'}]

‎src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public function testParsesServiceLocatorArgument()
282282
$loader =newXmlFileLoader($container,newFileLocator(self::$fixturesPath.'/xml'));
283283
$loader->load('services_locator_argument.xml');
284284

285-
$this->assertEquals(array(newServiceLocatorArgument(array('foo_baz' =>newReference('foo.baz'),'container' =>newReference('service_container'),'foo_string' =>'foo','foo_collection' =>array('foo')))),$container->getDefinition('lazy_context')->getArguments(),'->load() parses service-locator arguments');
285+
$this->assertEquals(array(newServiceLocatorArgument(array('foo_baz' =>newReference('foo.baz'),'container' =>newReference('service_container')))),$container->getDefinition('lazy_context')->getArguments(),'->load() parses service-locator arguments');
286286
$this->assertEquals(array(newServiceLocatorArgument(array('foo_baz' =>newReference('foo.baz'),'invalid' =>newReference('invalid', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)))),$container->getDefinition('lazy_context_ignore_invalid_ref')->getArguments(),'->load() parses service-locator arguments');
287287
}
288288

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp