I have tried a lot of method to resolv this problem, but it's still not working. What i want, is than after the user success to register he is redirecting to the wanted page.
So, i have a UserBundle with :
in UserBundle/EventListener
namespace MDB\UserBundle\EventListener; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use FOS\UserBundle\FOSUserEvents; use Symfony\Component\HttpFoundation\RedirectResponse; class RegistrationConfirmListener implements EventSubscriberInterface { private $router; public function __construct(UrlGeneratorInterface $router) { $this->router = $router; } /** * {@inheritDoc} */ public static function getSubscribedEvents() { return array( FOSUserEvents::REGISTRATION_CONFIRM => 'onRegistrationConfirm' ); } public function onRegistrationConfirm(GetResponseUserEvent $event) { $url = $this->router->generate('mdb_platform_homepage'); $event->setResponse(new RedirectResponse($url)); } } ?>in services.yml (of user bunde)
services:
mdb_user.registration.form.type: class: MDB\UserBundle\Form\Type\RegistrationFormType tags: - { name: form.type, alias: mdb_user_registration } mdb.user.validator.contains_user: class: MDB\UserBundle\Validator\Constraints\ContainsUserValidator arguments: [ "@doctrine.orm.entity_manager" ] tags: - { name: validator.constraint_validator, alias: contains_user } mdb_user.registration_complet: class: MDB\UserBundle\EventListener\RegistrationConfirmListener arguments: ["@router"] tags: - { name: kernel.event_subscriber }
i have tried a lot of other config and check the other forums but it seems the redirection never work.
Anyone have an idea? thanks in advance