FirewallMap.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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\Request;
  12. use Symfony\Component\HttpFoundation\RequestMatcherInterface;
  13. use Symfony\Component\Security\Http\Firewall\ExceptionListener;
  14. use Symfony\Component\Security\Http\Firewall\LogoutListener;
  15. /**
  16. * FirewallMap allows configuration of different firewalls for specific parts
  17. * of the website.
  18. *
  19. * @author Fabien Potencier <fabien@symfony.com>
  20. */
  21. class FirewallMap implements FirewallMapInterface
  22. {
  23. private $map = array();
  24. public function add(RequestMatcherInterface $requestMatcher = null, array $listeners = array(), ExceptionListener $exceptionListener = null, LogoutListener $logoutListener = null)
  25. {
  26. $this->map[] = array($requestMatcher, $listeners, $exceptionListener, $logoutListener);
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function getListeners(Request $request)
  32. {
  33. foreach ($this->map as $elements) {
  34. if (null === $elements[0] || $elements[0]->matches($request)) {
  35. return array($elements[1], $elements[2], $elements[3]);
  36. }
  37. }
  38. return array(array(), null, null);
  39. }
  40. }