From ffacec12c30c85c2e0f7d078aecb31db3a7ba5ca Mon Sep 17 00:00:00 2001 From: Robin Chalas Date: Mon, 10 Oct 2016 20:24:10 +0200 Subject: [PATCH] =?UTF-8?q?[SecurityBundle]=C2=A0Cache=20contexts=20per=20?= =?UTF-8?q?request=20in=20FirewallMap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Bundle/SecurityBundle/Security/FirewallMap.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php b/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php index dc87681c3751..da79e3c8c292 100644 --- a/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php +++ b/src/Symfony/Bundle/SecurityBundle/Security/FirewallMap.php @@ -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(); } }