2017-03-04 139 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: 
相關問題