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 8b24706

Browse filesBrowse files
committed
[Security] Lazy load request matchers
1 parent bcf8b68 commit 8b24706
Copy full SHA for 8b24706

File tree

7 files changed

+76
-13
lines changed
Filter options

7 files changed

+76
-13
lines changed

‎UPGRADE-3.3.md

Copy file name to clipboardExpand all lines: UPGRADE-3.3.md
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ SecurityBundle
5858
* The `FirewallContext::getContext()` method has been deprecated and will be removed in 4.0.
5959
Use the `getListeners()` method instead.
6060

61+
* The `FirewallContext::$map` property has been deprecated and will be removed in 4.0.
62+
Use the `FirewallContext::$contextMap` property instead.
63+
6164
TwigBridge
6265
----------
6366

‎UPGRADE-4.0.md

Copy file name to clipboardExpand all lines: UPGRADE-4.0.md
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,8 @@ SecurityBundle
163163
--------------
164164

165165
* The `FirewallContext::getContext()` method has been removed, use the `getListeners()` method instead.
166+
167+
* The `FirewallContext::$map` property has been removed. Use the `FirewallContext::$contextMap` property instead.
166168

167169
HttpFoundation
168170
---------------

‎src/Symfony/Bundle/SecurityBundle/CHANGELOG.md

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/CHANGELOG.md
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
3.3.0
5+
-----
6+
7+
* Deprecated the `FirewallContext::$map` property in favor of `FirewallMap::$contextMap`.
8+
49
3.2.0
510
-----
611

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
2121
use Symfony\Component\DependencyInjection\ContainerBuilder;
2222
use Symfony\Component\DependencyInjection\Reference;
23+
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
2324
use Symfony\Component\Config\FileLocator;
2425
use Symfony\Component\Security\Core\Authorization\ExpressionLanguage;
2526

@@ -255,7 +256,7 @@ private function createFirewalls($config, ContainerBuilder $container)
255256

256257
$map[$contextId] = $matcher;
257258
}
258-
$mapDef->replaceArgument(1, $map);
259+
$mapDef->replaceArgument(1, new IteratorArgument($map));
259260

260261
// add authentication providers to authentication manager
261262
$authenticationProviders = array_map(function ($id) {

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Resources/config/security.xml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105

106106
<service id="security.firewall.map" class="Symfony\Bundle\SecurityBundle\Security\FirewallMap" public="false">
107107
<argument type="service" id="service_container" />
108-
<argument type="collection" />
108+
<argument />
109109
</service>
110110

111111
<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
+61-9Lines changed: 61 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,19 @@
2424
*/
2525
class FirewallMap implements FirewallMapInterface
2626
{
27-
protected $container;
27+
/**
28+
* @deprecated since version 3.3, to be removed in 4.0 alongside with magic methods below
29+
*/
2830
protected $map;
29-
private $contexts;
31+
protected $container;
32+
private $contextCache;
33+
private $contextMap;
3034

31-
public function __construct(ContainerInterface $container, array $map)
35+
public function __construct(ContainerInterface $container, $contextMap)
3236
{
3337
$this->container = $container;
34-
$this->map = $map;
35-
$this->contexts = new \SplObjectStorage();
38+
$this->contextCache = new \SplObjectStorage();
39+
$this->contextMap = $contextMap;
3640
}
3741

3842
/**
@@ -65,14 +69,62 @@ public function getFirewallConfig(Request $request)
6569

6670
private function getFirewallContext(Request $request)
6771
{
68-
if ($this->contexts->contains($request)) {
69-
return $this->contexts[$request];
72+
if ($this->contextCache->contains($request)) {
73+
return $this->contextCache[$request];
7074
}
7175

72-
foreach ($this->map as $contextId => $requestMatcher) {
76+
foreach ($this->contextMap as $contextId => $requestMatcher) {
7377
if (null === $requestMatcher || $requestMatcher->matches($request)) {
74-
return $this->contexts[$request] = $this->container->get($contextId);
78+
return $this->contextCache[$request] = $this->container->get($contextId);
7579
}
7680
}
7781
}
82+
83+
/**
84+
* @internal
85+
*/
86+
public function __get($name)
87+
{
88+
if ('map' === $name) {
89+
@trigger_error(sprintf('Using the "%s::$map" property is deprecated since version 3.3 as it will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
90+
}
91+
92+
return $this->$name;
93+
}
94+
95+
/**
96+
* @internal
97+
*/
98+
public function __set($name, $value)
99+
{
100+
if ('map' === $name) {
101+
@trigger_error(sprintf('Using the "%s::$map" property is deprecated since version 3.3 as it will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
102+
}
103+
104+
$this->$name = $value;
105+
}
106+
107+
/**
108+
* @internal
109+
*/
110+
public function __isset($name)
111+
{
112+
if ('map' === $name) {
113+
@trigger_error(sprintf('Using the "%s::$map" property is deprecated since version 3.3 as it will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
114+
}
115+
116+
return isset($this->$name);
117+
}
118+
119+
/**
120+
* @internal
121+
*/
122+
public function __unset($name)
123+
{
124+
if ('map' === $name) {
125+
@trigger_error(sprintf('Using the "%s::$map" property is deprecated since version 3.3 as it will be removed in 4.0.', __CLASS__), E_USER_DEPRECATED);
126+
}
127+
128+
unset($this->$name);
129+
}
78130
}

‎src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/SecurityBundle/Tests/DependencyInjection/CompleteConfigurationTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function testFirewalls()
6868
$arguments = $container->getDefinition('security.firewall.map')->getArguments();
6969
$listeners = array();
7070
$configs = array();
71-
foreach (array_keys($arguments[1]) as $contextId) {
71+
foreach (array_keys($arguments[1]->getValues()) as $contextId) {
7272
$contextDef = $container->getDefinition($contextId);
7373
$arguments = $contextDef->getArguments();
7474
$listeners[] = array_map(function ($ref) { return (string) $ref; }, $arguments['index_0']);
@@ -180,7 +180,7 @@ public function testFirewallRequestMatchers()
180180
$arguments = $container->getDefinition('security.firewall.map')->getArguments();
181181
$matchers = array();
182182

183-
foreach ($arguments[1] as $reference) {
183+
foreach ($arguments[1]->getValues() as $reference) {
184184
if ($reference instanceof Reference) {
185185
$definition = $container->getDefinition((string) $reference);
186186
$matchers[] = $definition->getArguments();

0 commit comments

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