当用户进入系统登录时,我尝试创建一个事件,
我有这样的代码:
services:
login_listener:
class: mio\mioBundle\LoginListener
tags:
- { name: kernel.event_listener, event: security.interactive_login, method: onSecurityInteractiveLogin }
<?php
namespace mio\mioBundle;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\EventDispatcher\Event;
class LoginListener
{
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
{
}
}
?>
但在分析器中,没有称为侦听器的是什么?
发布于 2012-10-04 20:40:36
创建一个实现AuthenticationSuccessHandlerInterface
的服务,并将其设置为防火墙中的成功处理程序-在Security Configuration Reference页面上搜索success_handler
。您可以在onAuthenticationSuccess()
方法中实现所需的任何逻辑。
发布于 2013-11-26 22:36:46
您的代码是正确的方式。探查器显示未调用事件,这可能是登录后重定向的原因。分析器向您显示最新的请求-重定向之后的请求。如果你检查最后一个POST请求(对login_check)的分析器信息,你会发现事件实际上是被调用的。
https://stackoverflow.com/questions/12726136
复制相似问题