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

Commitb51d617

Browse files
committed
[Security] Lazy load request matchers
1 parent2183f98 commitb51d617

File tree

7 files changed

+79
-13
lines changed

7 files changed

+79
-13
lines changed

‎UPGRADE-3.3.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ 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+
6163
TwigBridge
6264
----------
6365

‎UPGRADE-4.0.md‎

Lines 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.
166168

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

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

Lines 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‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
useSymfony\Component\DependencyInjection\Loader\XmlFileLoader;
2121
useSymfony\Component\DependencyInjection\ContainerBuilder;
2222
useSymfony\Component\DependencyInjection\Reference;
23+
useSymfony\Component\DependencyInjection\Argument\IteratorArgument;
2324
useSymfony\Component\Config\FileLocator;
2425
useSymfony\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,newIteratorArgument($map));
259260

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105

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

111111
<serviceid="security.firewall.context"class="Symfony\Bundle\SecurityBundle\Security\FirewallContext"abstract="true">

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

Lines changed: 65 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,19 @@
2424
*/
2525
class FirewallMapimplements FirewallMapInterface
2626
{
27+
/**
28+
* @deprecated since version 3.3, to be removed in 4.0 alongside with magic methods below
29+
*/
30+
private$map;
2731
protected$container;
28-
protected$map;
29-
private$contexts;
32+
private$contextCache;
33+
private$contextMap;
3034

31-
publicfunction__construct(ContainerInterface$container,array$map)
35+
publicfunction__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,66 @@ public function getFirewallConfig(Request $request)
6569

6670
privatefunctiongetFirewallContext(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->mapas$contextId =>$requestMatcher) {
76+
foreach ($this->contextMapas$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);
79+
}
80+
}
81+
}
82+
83+
/**
84+
* @internal
85+
*/
86+
publicfunction__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+
if ($this->contextMapinstanceof \Iterator) {
92+
$this->map =iterator_to_array($this->contextMap);
7593
}
7694
}
95+
96+
return$this->$name;
97+
}
98+
99+
/**
100+
* @internal
101+
*/
102+
publicfunction__set($name,$value)
103+
{
104+
if ('map' ===$name) {
105+
@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);
106+
}
107+
108+
$this->$name =$value;
109+
}
110+
111+
/**
112+
* @internal
113+
*/
114+
publicfunction__isset($name)
115+
{
116+
if ('map' ===$name) {
117+
@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);
118+
}
119+
120+
returnisset($this->$name);
121+
}
122+
123+
/**
124+
* @internal
125+
*/
126+
publicfunction__unset($name)
127+
{
128+
if ('map' ===$name) {
129+
@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);
130+
}
131+
132+
unset($this->$name);
77133
}
78134
}

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

Lines 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 ($referenceinstanceof Reference) {
185185
$definition =$container->getDefinition((string)$reference);
186186
$matchers[] =$definition->getArguments();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp