FriendsOfSymfony / FOSUserBundle

Provides user management for your Symfony project. Compatible with Doctrine ORM & ODM, and custom storages.

Home Page:https://symfony.com/doc/master/bundles/FOSUserBundle/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is the REGISTRATION_FAILURE event actually listened for?

MPLLC opened this issue · comments

I'm having an issue with extending the bundle's registration form. Specifically, block level errors that should be displayed with {{ form_errors(form) }} are not being rendered. Looking into it, it seems that an invalid registration form throws a REGISTRATION_FAILURE event. I cannot find where this event is listened to/handled, however. The invalid state seems to expect a response from the event, which if not null it simply returns. Lines 90-96 of RegistrationController.php:

$event = new FormEvent($form, $request);
$this->eventDispatcher->dispatch(FOSUserEvents::REGISTRATION_FAILURE, $event);

if (null !== $response = $event->getResponse()) {
    return $response;
}

Of course, if there isn't a listener, then the response would be null, and nothing would happen outside of the method simply ending due to the way the if/else blocks are written (it should probably be rewritten as if ($form->isSubmitted() && $form->isValid()){ /* ... */} to ensure that the form is rendered upon failure of either/both).

So, questions: is there a listener for this event? If so, where? And if not, what should be done, since I haven't found anything in the docs regarding it?

The lesson, as always, is that I'm an idiot. What I thought was an event listener problem was actually a case of missing error_bubbling.