CustomAuthenticationFailureHandler.php 1.3 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\Authentication;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\Security\Core\Exception\AuthenticationException;
  13. /**
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. */
  16. class CustomAuthenticationFailureHandler implements AuthenticationFailureHandlerInterface
  17. {
  18. private $handler;
  19. /**
  20. * @param AuthenticationFailureHandlerInterface $handler An AuthenticationFailureHandlerInterface instance
  21. * @param array $options Options for processing a successful authentication attempt
  22. */
  23. public function __construct(AuthenticationFailureHandlerInterface $handler, array $options)
  24. {
  25. $this->handler = $handler;
  26. if (method_exists($handler, 'setOptions')) {
  27. $this->handler->setOptions($options);
  28. }
  29. }
  30. /**
  31. * {@inheritdoc}
  32. */
  33. public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
  34. {
  35. return $this->handler->onAuthenticationFailure($request, $exception);
  36. }
  37. }