HWIOauthBundle& FOSUserBundle事件未触发 [英] HWIOauthBundle & FOSUserBundle events not firing

查看:187
本文介绍了HWIOauthBundle& FOSUserBundle事件未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已遵循此处的所有建议,使用FOSUserBundle设置HWIOAuthBundle ,但我希望能够访问用户注册时触发的事件,但到目前为止似乎无法执行该操作.遵循此问题中的建议,这是我的活动订阅者(请注意,我对所有事件都不感兴趣,但是我只是想测试是否有任何事件被触发):

I have followed all of the advice found here for setting up the HWIOAuthBundle with the FOSUserBundle, but I wish to be able to access the events fired when a user registers and so far seem unable to do that. Having followed the advice in this question, here is my event subscriber (note that I am not interested in all of the events, but I just wanted to test if any of them were being fired):

<?php
namespace Acme\ClientBundle\EventListener;

use FOS\UserBundle\Event\FilterUserResponseEvent;
use FOS\UserBundle\Event\FormEvent;
use FOS\UserBundle\Event\GetResponseUserEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use FOS\UserBundle\FOSUserEvents;
use FOS\UserBundle\Event\UserEvent;
use Symfony\Bridge\Monolog\Logger;

/**
 * RegistrationConfirmListener
 */
class RegistrationConfirmListener implements EventSubscriberInterface
{
    /**
     * @var Logger
     */
    private $logger;

    function __construct(UrlGeneratorInterface $router, Logger $logger)
    {
        $this->router = $router;
        $this->logger = $logger;
    }

    public static function getSubscribedEvents()
    {
        return array(
            FOSUserEvents::REGISTRATION_INITIALIZE => 'onRegistrationInit',
            FOSUserEvents::REGISTRATION_CONFIRM    => 'onRegistrationConfirm',
            FOSUserEvents::REGISTRATION_CONFIRMED  => 'onRegistrationConfirmed',
            FOSUserEvents::REGISTRATION_COMPLETED  => 'onRegistrationCompleted',
            FOSUserEvents::REGISTRATION_SUCCESS    => 'onRegistrationSuccess',
        );
    }

    public function onRegistrationInit(UserEvent $event)
    {
        $this->logger->info('Registration has started: ' . serialize($event));
    }

    public function onRegistrationConfirm(GetResponseUserEvent $event)
    {
        $this->logger->info("Registration is confirming: " . serialize($event));
    }

    public function onRegistrationConfirmed(FilterUserResponseEvent $event)
    {
        $this->logger->info("Registration has been confirmed: " . serialize($event));
    }

    public function onRegistrationCompleted(FilterUserResponseEvent $event)
    {
        $this->logger->info("Registration has been completed: " . serialize($event));
    }

    public function onRegistrationSuccess(FormEvent $event)
    {
        $this->logger->info("Registration has been successful: " . serialize($event));
    }
}

这是我的服务定义:

acme_user.registration_complete:
    class: Acme\ClientBundle\EventListener\RegistrationConfirmListener
    arguments: [ @router, @logger ]
    tags:
        - { name: kernel.event_subscriber }

但是,即使身份验证/注册成功,我也看不到任何FOSUserEvents被记录.我所感觉到的唯一可能相关的其他信息是,我还将FOSUserBundle与SonataAdminBundle集成在一起,这似乎也可以正常工作. (好吧,一旦我弄清楚了如何将FOSUserBundle升级到v2.0并修复了所需的更改,就正确了.)

However I cannot see any of the FOSUserEvents being logged, even though the authentication/registration is successful. The only other information I have that I feel may be relevant is that I am also integrating the FOSUserBundle with then SonataAdminBundle, which also seems to be working correctly. (Well, correctly once I figured out how to upgrade the FOSUserBundle to v2.0 and fixed the changes required.)

有人能知道我在这里想念的什么吗?

Does anyone have any idea what I am missing here to be able to hook into these events?

推荐答案

结果表明,HWIOAuthBundle不使用FOSUserBundle注册控制器,因此它将永远不会触发这些事件.

Turns out that the HWIOAuthBundle does not use the FOSUserBundle registration controller so it will never fire those events.

这篇关于HWIOauthBundle&amp; FOSUserBundle事件未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆