我知道这个问题已经发布了,我确实尝试了一些(如果不是所有的)我找到的答案,但还没有成功,因此这是我的问题:
我刚刚安装了一个新的Symfony应用程序并成功安装了FOSUserBundle,对UserEntity和FormRegistrationType进行了一些修改(添加了一些字段,......)
然后,我尝试按照本教程:http://symfony.com/doc/master/bundles/FOSUserBundle/controller_events.html
这是我的services.yml:
app.suscriber.authentification:
class: MyBundle\Suscriber\AuthSubscriber
arguments: [ "@doctrine" ]
tags:
- { name: kernel.event.suscriber }
这是我的AuthSuscriber类=>
<?php
namespace MyBundle\Suscriber;
use MyBundle\Entity\User;
use Doctrine\Bundle\DoctrineBundle\Registry;
use FOS\UserBundle\Event\FilterUserResponseEvent;
use FOS\UserBundle\Event\UserEvent;
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Security\LoginManagerInterface;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class AuthSubscriber implements EventSubscriberInterface
{
protected $doctrine;
protected $user;
public function __construct(Doctrine $doctrine)
{
$this->doctrine = $doctrine;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents()
{
return array(
FOSUserEvents::REGISTRATION_COMPLETED => 'onRegistrationSuccess',
FOSUserEvents::REGISTRATION_CONFIRMED => 'onRegistrationSuccess',
);
}
public function onRegistrationSuccess(FilterUserResponseEvent $event, $eventName, EventDispatcherInterface $eventDispatcher)
{
dump('here, but not seen at any time');die();
}
}
我确实在控制台上看到了我的服务:
php bin/console debug:container app.suscriber.authentification
但以下命令行不以任何方式显示我的订阅者=&gt;
php bin/console debug:event-dispatcher | grep "fos_user.registration" -A10
使用以下输出=&gt;
即使它显示来自FOS \ UserBundle的AuthentificationListener ......
如果有人能给我一个关于如何调试这种bug的提示,我很乐意听他说,因为我在这里完全迷失了&gt; ____&lt;“
谢谢,
哈林
答案 0 :(得分:1)
标签名称中是否有拼写错误?下划线 _ 而不是。
app.suscriber.authentification:
class: MyBundle\Suscriber\AuthSubscriber
arguments: [ "@doctrine" ]
tags:
- { name: kernel.event_subscriber }