没有扩展程序可以加载配置service.yml

时间:2017-03-04 10:27:34

标签: symfony symfony1

我创建了登录的事件列表,但我在配置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 }

这个问题:

enter image description here

请帮助我,谢谢

1 个答案:

答案 0 :(得分:0)

这是YML格式错误。在services.yml中,您的缩进错误,而项dbla_user.login_listener被解释为父项。请注意区别:

services:
  ...
  ...
  dbla_user.login_listener:

services:
  ...
  ...
dbla_user.login_listener: