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

Appearance settings

Commit bb455aa

Browse filesBrowse files
committed
[SecurityBundle] Avoid container injection in FirewallMap
1 parent bbaea98 commit bb455aa
Copy full SHA for bb455aa

File tree

11 files changed

+12
-21
lines changed
Filter options

11 files changed

+12
-21
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
+4-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml
+2-2Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php
+1-4Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Argument/ServiceLocatorArgument.php
+1-3Lines changed: 1 addition & 3 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
*
@@ -25,7 +23,7 @@ class ServiceLocatorArgument implements ArgumentInterface
2523
private $values;
2624

2725
/**
28-
* @param array $values An array of mixed entries indexed by identifier
26+
* @param array $values An array of references entries indexed by identifier
2927
*/
3028
public function __construct(array $values)
3129
{

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php
-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Loader/YamlFileLoader.php
-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php
+1-2Lines 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');

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services_locator_argument.xml
-4Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
<argument type="service-locator">
1414
<argument key="foo_baz" type="service" id="foo.baz"/>
1515
<argument key="container" type="service" id="service_container"/>
16-
<argument key="foo_string">foo</argument>
17-
<argument key="foo_collection" type="collection">
18-
<argument>foo</argument>
19-
</argument>
2016
</argument>
2117
</service>
2218
<service id="lazy_context_ignore_invalid_ref" class="LazyContext">

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services_locator_argument.yml
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public function testParsesServiceLocatorArgument()
282282
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
283283
$loader->load('services_locator_argument.xml');
284284

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

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ public function testParsesServiceLocatorArgument()
360360
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
361361
$loader->load('services_locator_argument.yml');
362362

363-
$this->assertEquals(array(new ServiceLocatorArgument(array('foo_baz' => new Reference('foo.baz'), 'container' => new Reference('service_container'), 'foo_string' => 'foo', 'foo_collection' => array('foo')))), $container->getDefinition('lazy_context')->getArguments(), '->load() parses service-locator arguments');
363+
$this->assertEquals(array(new ServiceLocatorArgument(array('foo_baz' => new Reference('foo.baz'), 'container' => new Reference('service_container')))), $container->getDefinition('lazy_context')->getArguments(), '->load() parses service-locator arguments');
364364
$this->assertEquals(array(new ServiceLocatorArgument(array('foo_baz' => new Reference('foo.baz'), 'invalid' => new Reference('invalid', ContainerInterface::IGNORE_ON_INVALID_REFERENCE)))), $container->getDefinition('lazy_context_ignore_invalid_ref')->getArguments(), '->load() parses service-locator arguments');
365365
}
366366

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.