2017-03-04 3 views
-1

設定service.ymlをロードすることができ拡張子はありませんが、私は、構成services.ymlにproblemeいるあり、私は、ログインのイベントリスタを作成

コード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

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

[Symfony2の:のための設定をロードすることができ拡張子はありません]の可能な重複(http://stackoverflow.com/questions/16122641/symfony2-拡張が不可能な構成をロードすることができる) – DonCallisto

答えて

0

これはYMLフォーマットエラーです。 services.ymlではインデントが間違っており、dbla_user.login_listenerという項目は親項目として解釈されます。違いに注目してください:

services: 
    ... 
    ... 
dbla_user.login_listener: 
関連する問題