1

This question relates to

How to disable redirection after login_check in Symfony 2

I have implemented the solution given at that link exactly but am receiving an error I usually understand but on this occasion do not. My class absolutely implements the interface perfectly (I think).

Fatal error: Declaration of Foo\AppBundle\Handler\AuthenticationHandler::onAuthenticationSuccess() must be compatible with that of Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface::onAuthenticationSuccess() in /Users/Me/Sites/github/Foo/Symfony/src/Foo/AppBundle/Handler/AuthenticationHandler.php on line 6

class AuthenticationHandler implements
\Symfony\Component\Security\Http\Authentication\AuthenticationSuccessHandlerInterface,
\Symfony\Component\Security\Http\Authentication\AuthenticationFailureHandlerInterface
{
    function onAuthenticationSuccess(Request $request, TokenInterface $token) {
        return new Response();
    }

    function onAuthenticationFailure(Request $request, AuthenticationException $exception) {
        return new Response();
    }
}

Advice appreciated!

Community
  • 1
  • 1
PorridgeBear
  • 1,183
  • 1
  • 12
  • 19

1 Answers1

5

PHP thinks that Request, TokenInterface are from the current namespace but the interfaces' declaration requires them to be from Symfony\* namespace. Try to add using statements or use FQN for these classes:

use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
meze
  • 14,975
  • 4
  • 47
  • 52