Я знаю, что этот вопрос уже был опубликован, и я попробовал некоторые, если не все ответы, которые нашел, но безуспешно, поэтому вот мой вопрос:
Я только что установил новое приложение 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
Но следующая командная строка никак не показывает моего подписчика =>
php bin/console debug:event-dispatcher | grep "fos_user.registration" -A10
Со следующим выводом =>
Даже если он показывает AuthentificationListener из FOS \ UserBundle …
Если бы кто-нибудь мог дать мне подсказку о том, как отладить такого рода ошибку, я бы с удовольствием выслушал его, потому что я полностью потерян здесь> ____<«
Спасибо,
Хурин
В названии тега нет опечатки? Нижнее подчеркивание _ вместо .
app.suscriber.authentification:
class: MyBundle\Suscriber\AuthSubscriber
arguments: [ "@doctrine" ]
tags:
- { name: kernel.event_subscriber }
Других решений пока нет …