CustomAuthenticationFailureHandler.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 array $options Options for processing a successful authentication attempt
  21. */
  22. public function __construct(AuthenticationFailureHandlerInterface $handler, array $options)
  23. {
  24. $this->handler = $handler;
  25. if (method_exists($handler, 'setOptions')) {
  26. $this->handler->setOptions($options);
  27. }
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. public function onAuthenticationFailure(Request $request, AuthenticationException $exception)
  33. {
  34. return $this->handler->onAuthenticationFailure($request, $exception);
  35. }
  36. }