8000 [SecurityBundle] Cache contexts per request in FirewallMap · symfony/symfony@ffacec1 · GitHub
[go: up one dir, main page]

Skip to content

Commit ffacec1

Browse files
committed
[SecurityBundle] Cache contexts per request in FirewallMap
1 parent a5d134b commit ffacec1

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,24 @@ class FirewallMap implements FirewallMapInterface
2626
{
2727
protected $container;
2828
protected $map;
29+
private $contexts;
2930

3031
public function __construct(ContainerInterface $container, array $map)
3132
{
3233
$this->container = $container;
3334
$this->map = $map;
35+
$this->contexts = new \SplObjectStorage();
3436
}
3537

3638
public function getListeners(Request $request)
3739
{
40+
if ($this->contexts->contains($request)) {
41+
return $this->contexts[$request];
42+
}
43+
3844
foreach ($this->map as $contextId => $requestMatcher) {
3945
if (null === $< 565B /span>requestMatcher || $requestMatcher->matches($request)) {
40-
return $this->container->get($contextId)->getContext();
46+
return $this->contexts[$request] = $this->container->get($contextId)->getContext();
4147
}
4248
}
4349

0 commit comments

Comments
 (0)
0