Php 注册确认监听器&;FOSUserBundle
我尝试在使用侦听器注册后将新用户重定向到欢迎页面。但我没有结果。我确实喜欢那一页上写的。请帮忙。代码如下:Php 注册确认监听器&;FOSUserBundle,php,symfony,fosuserbundle,event-listener,Php,Symfony,Fosuserbundle,Event Listener,我尝试在使用侦听器注册后将新用户重定向到欢迎页面。但我没有结果。我确实喜欢那一页上写的。请帮忙。代码如下: namespace Acme\UserBundle\EventListener; use FOS\UserBundle\Event\GetResponseUserEvent; use FOS\UserBundle\FOSUserEvents; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfo
namespace Acme\UserBundle\EventListener;
use FOS\UserBundle\Event\GetResponseUserEvent;
use FOS\UserBundle\FOSUserEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
/**
* Listener responsible to change the redirection at the end of the password resetting
*/
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('_welcome');
$event->setResponse(new RedirectResponse($url));
}
}
我的服务:
<service id="acme_user.registration.confirmed" class="Acme\UserBundle\EventListener\RegistrationConfirmListener">
<tag name="kernel.event_subscriber"/>
<argument type="service" id="router"/>
</service>
我只需要使用
注册\u SUCCESS
来代替注册\u CONFIRM
。一切都好