2017-03-04 144 views
-1

我创建登录的事件利斯特但我在配置services.yml已经probleme没有扩展能够加载配置service.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; 

     } 
     } 
    } 

代码services.yml:

dbla_user.login_listener: 
    class: Enso\UserBundle\EventListener\LoginListener 
    arguments: [@doctrine] 
    tags: 
     - { name: kernel.event_listener, event: security.interactive_login, method: onLogin } 

这probleme:

enter image description here

请帮助我,谢谢

+0

的可能的复制[Symfony2的:没有扩展能够加载用于配置](http://stackoverflow.com/questions/16122641/symfony2-有此结果没有延伸-能够对负载的配置换) – DonCallisto

回答

0

这是一个YML格式错误。在您的services.yml中,您有一个错误的缩进,并且项目dbla_user.login_listener被解释为父项。注意到其中的差别:

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

services: 
    ... 
    ... 
dbla_user.login_listener: 
相关问题