【问题标题】:Custom AuthenticationHandler not implementing interface correctly - why?自定义 AuthenticationHandler 未正确实现接口 - 为什么?
【发布时间】:2012-01-04 20:00:31
【问题描述】:

这个问题涉及到

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();
    }
}

建议!

【问题讨论】:

    标签: symfony


    【解决方案1】:

    PHP 认为 RequestTokenInterface 来自当前命名空间,但接口的声明要求它们来自 Symfony\* 命名空间。 尝试为这些类添加 using 语句或使用 FQN:

    use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
    use Symfony\Component\HttpFoundation\Request;
    use Symfony\Component\Security\Core\Exception\AuthenticationException;
    

    【讨论】:

    • 哇。我怎么错过了:) 非常感谢
    • 非常感谢 :)
    猜你喜欢
    • 2016-07-09
    • 1970-01-01
    • 2018-07-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-30
    • 1970-01-01
    相关资源
    最近更新 更多