Skip to content

Commit

Permalink
[SecurityBundle] Cache contexts per request in FirewallMap
Browse files Browse the repository at this point in the history
  • Loading branch information
chalasr committed Oct 10, 2016
1 parent a5d134b commit ffacec1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php
Expand Up @@ -26,18 +26,24 @@ class FirewallMap implements FirewallMapInterface
{
protected $container;
protected $map;
private $contexts;

public function __construct(ContainerInterface $container, array $map)
{
$this->container = $container;
$this->map = $map;
$this->contexts = new \SplObjectStorage();
}

public function getListeners(Request $request)
{
if ($this->contexts->contains($request)) {
return $this->contexts[$request];
}

foreach ($this->map as $contextId => $requestMatcher) {
if (null === $requestMatcher || $requestMatcher->matches($request)) {
return $this->container->get($contextId)->getContext();
return $this->contexts[$request] = $this->container->get($contextId)->getContext();
}
}

Expand Down

0 comments on commit ffacec1

Please sign in to comment.