自定义AuthenticationHandler没有正确实现接口 - 为什么?
问题描述:
这个问题涉及到自定义AuthenticationHandler没有正确实现接口 - 为什么?
How to disable redirection after login_check in Symfony 2
我已经实现了该链接正好给出的解决方案,但我收到一条错误我通常理解,但这次没有。我的课完全实现了界面(我认为)。
致命错误:Foo \ AppBundle \ Handler \ AuthenticationHandler :: onAuthenticationSuccess()声明必须与/ Users/Me/Sites中的Symfony \ Component \ Security \ Http \ Authentication \ AuthenticationSuccessHandlerInterface :: onAuthenticationSuccess()兼容/github/Foo/Symfony/src/Foo/AppBundle/Handler/AuthenticationHandler.php第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();
}
}
建议表示赞赏!
答
PHP认为Request
,TokenInterface
来自当前命名空间,但接口声明要求它们来自Symfony\*
命名空间。 尝试添加使用语句或使用这些类的FQN:
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
哇。我怎么错过:)非常感谢 – PorridgeBear 2012-01-04 21:23:11
非常感谢你:) – 2016-12-20 17:40:30