equal
deleted
inserted
replaced
|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of the Symfony framework. |
|
5 * |
|
6 * (c) Fabien Potencier <fabien@symfony.com> |
|
7 * |
|
8 * This source file is subject to the MIT license that is bundled |
|
9 * with this source code in the file LICENSE. |
|
10 */ |
|
11 |
|
12 namespace Symfony\Bundle\SecurityBundle\Security; |
|
13 |
|
14 use Symfony\Component\Security\Http\FirewallMapInterface; |
|
15 use Symfony\Component\HttpFoundation\Request; |
|
16 use Symfony\Component\DependencyInjection\ContainerInterface; |
|
17 |
|
18 /** |
|
19 * This is a lazy-loading firewall map implementation |
|
20 * |
|
21 * Listeners will only be initialized if we really need them. |
|
22 * |
|
23 * @author Johannes M. Schmitt <schmittjoh@gmail.com> |
|
24 */ |
|
25 class FirewallMap implements FirewallMapInterface |
|
26 { |
|
27 protected $container; |
|
28 protected $map; |
|
29 |
|
30 public function __construct(ContainerInterface $container, array $map) |
|
31 { |
|
32 $this->container = $container; |
|
33 $this->map = $map; |
|
34 } |
|
35 |
|
36 public function getListeners(Request $request) |
|
37 { |
|
38 foreach ($this->map as $contextId => $requestMatcher) { |
|
39 if (null === $requestMatcher || $requestMatcher->matches($request)) { |
|
40 return $this->container->get($contextId)->getContext(); |
|
41 } |
|
42 } |
|
43 |
|
44 return array(array(), null); |
|
45 } |
|
46 } |