8000 Lazy load security listeners · symfony/symfony@3f97646 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3f97646

Browse files
committed
Lazy load security listeners
1 parent e4e1b81 commit 3f97646

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

src/Symfony/Bundle/SecurityBundle/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
3.4.0
5+
-----
6+
7+
* [BC BREAK] `FirewallContext::getListeners()` now returns a `\Traversable` object by default instead of an
8+
array
9+
410
3.3.0
511
-----
612

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ private function createFirewalls($config, ContainerBuilder $container)
265265
$contextId = 'security.firewall.map.context.'.$name;
266266
$context = $container->setDefinition($contextId, new ChildDefinition('security.firewall.context'));
267267
$context
268-
->replaceArgument(0, $listeners)
268+
->replaceArgument(0, new IteratorArgument($listeners))
269269
->replaceArgument(1, $exceptionListener)
270270
->replaceArgument(2, new Reference($configId))
271271
;

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class FirewallContext
2525
private $exceptionListener;
2626
private $config;
2727

28-
public function __construct(array $listeners, ExceptionListener $exceptionListener = null, FirewallConfig $config = null)
28+
public function __construct(/* iterable */ $listeners, ExceptionListener $exceptionListener = null, FirewallConfig $config = null)
2929
{
3030
$this->listeners = $listeners;
3131
$this->exceptionListener = $exceptionListener;
@@ -49,6 +49,12 @@ public function getContext()
4949

5050
public function getListeners()
5151
{
52+
if (is_array($this->listeners)) {
53+
@trigger_error
54+
55+
return iterator_to_array($this->listeners);
56+
}
57+
5258
return $this->listeners;
5359
}
5460

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public function testFirewalls()
7272
foreach (array_keys($arguments[1]->getValues()) as $contextId) {
7373
$contextDef = $container->getDefinition($contextId);
7474
$arguments = $contextDef->getArguments();
75-
$listeners[] = array_map('strval', $arguments['index_0']);
75+
$listeners[] = array_map('strval', $arguments['index_0']->getValues());
7676

7777
$configDef = $container->getDefinition((string) $arguments['index_2']);
7878
$configs[] = array_values($configDef->getArguments());

0 commit comments

Comments
 (0)
0