我创建了登录的事件列表,但我在配置services.yml
中遇到了问题代码LoginListener:
<?php
namespace Enso\UserBundle\EventListener;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Symfony\Bundle\DoctrineBundle\Registry as Doctrine;
class LoginListener
{
protected $doctrine;
public function __construct(Doctrine $doctrine)
{
$this->doctrine = $doctrine;
}
public function onLogin(InteractiveLoginEvent $event)
{
$user = $event->getAuthenticationToken()->getUser();
if($user)
{
setNbrelog() = getNbrelog()+1;
}
}
}
code services.yml:
dbla_user.login_listener:
class: Enso\UserBundle\EventListener\LoginListener
arguments: [@doctrine]
tags:
- { name: kernel.event_listener, event: security.interactive_login, method: onLogin }
这个问题:
请帮助我,谢谢
答案 0 :(得分:0)
这是YML格式错误。在services.yml
中,您的缩进错误,而项dbla_user.login_listener
被解释为父项。请注意区别:
services:
...
...
dbla_user.login_listener:
与
services:
...
...
dbla_user.login_listener: