CustomAuthenticationSuccessHandler.php 1.5 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\Authentication;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
  13. /**
  14. * @author Fabien Potencier <fabien@symfony.com>
  15. */
  16. class CustomAuthenticationSuccessHandler implements AuthenticationSuccessHandlerInterface
  17. {
  18. private $handler;
  19. /**
  20. * @param AuthenticationSuccessHandlerInterface $handler An AuthenticationSuccessHandlerInterface instance
  21. * @param array $options Options for processing a successful authentication attempt
  22. * @param string $providerKey The provider key
  23. */
  24. public function __construct(AuthenticationSuccessHandlerInterface $handler, array $options, $providerKey)
  25. {
  26. $this->handler = $handler;
  27. if (method_exists($handler, 'setOptions')) {
  28. $this->handler->setOptions($options);
  29. }
  30. if (method_exists($handler, 'setProviderKey')) {
  31. $this->handler->setProviderKey($providerKey);
  32. }
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function onAuthenticationSuccess(Request $request, TokenInterface $token)
  38. {
  39. return $this->handler->onAuthenticationSuccess($request, $token);
  40. }
  41. }