FirewallMap.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Security\Http;
  11. use Symfony\Component\HttpFoundation\RequestMatcherInterface;
  12. use Symfony\Component\HttpFoundation\Request;
  13. use Symfony\Component\Security\Http\Firewall\ExceptionListener;
  14. /**
  15. * FirewallMap allows configuration of different firewalls for specific parts
  16. * of the website.
  17. *
  18. * @author Fabien Potencier <fabien@symfony.com>
  19. */
  20. class FirewallMap implements FirewallMapInterface
  21. {
  22. private $map = array();
  23. public function add(RequestMatcherInterface $requestMatcher = null, array $listeners = array(), ExceptionListener $exceptionListener = null)
  24. {
  25. $this->map[] = array($requestMatcher, $listeners, $exceptionListener);
  26. }
  27. public function getListeners(Request $request)
  28. {
  29. foreach ($this->map as $elements) {
  30. if (null === $elements[0] || $elements[0]->matches($request)) {
  31. return array($elements[1], $elements[2]);
  32. }
  33. }
  34. return array(array(), null);
  35. }
  36. }