Events FOSUserBundle Symfony2 on register and login

空扰寡人 提交于 2019-12-03 00:39:14
Emii Khaos

Two points:

  1. In the service definition - { name: 'kernel.event_subscriber'} is enough, no event entry. This the difference between subscriber and listener. A listener can only listen to one event, defined trough event and method params in the service definition. A subscriber can listen to multiple events, defined trough the method getSubscribedEvents(), so no further params in the service definition needed.

  2. Second point, you are type hinting against the event classes (UserEvent andFilterUserResponseEvent), but you never imported them, so PHP assumes them in the same namespace (as said in the error message).

    use FOS\UserBundle\Event\UserEvent;
    use FOS\UserBundle\Event\FilterUserResponseEvent;
    
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!