我想重載方法FOS FlashListener::getSubscribedEvents()
,只是徵求意見REGISTRATION_COMPLETED
行:FOSUserBundle FlashListener刪除REGISTRATION_COMPLETED消息
// vendor/friendsofsymfony/user-bundle/EventListener/FlashListener.php
public static function getSubscribedEvents() {
return array(
FOSUserEvents::CHANGE_PASSWORD_COMPLETED => 'addSuccessFlash',
FOSUserEvents::GROUP_CREATE_COMPLETED => 'addSuccessFlash',
FOSUserEvents::GROUP_DELETE_COMPLETED => 'addSuccessFlash',
FOSUserEvents::GROUP_EDIT_COMPLETED => 'addSuccessFlash',
FOSUserEvents::PROFILE_EDIT_COMPLETED => 'addSuccessFlash',
FOSUserEvents::REGISTRATION_COMPLETED => 'addSuccessFlash',
FOSUserEvents::RESETTING_RESET_COMPLETED => 'addSuccessFlash',
);
}
有一些相關信息有:
// vendor/friendsofsymfony/user-bundle/Resources/config/flash_notifications.xml
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="fos_user.listener.flash" class="FOS\UserBundle\EventListener\FlashListener">
<tag name="kernel.event_subscriber" />
<argument type="service" id="session" />
<argument type="service" id="translator" />
</service>
</services>
</container>
我已經做到了:
<?php
// src/XXXX/UserBundle/EventListener/FlashListener.php
namespace XXXX\UserBundle\EventListener;
use FOS\UserBundle\EventListener\FlashListener AS BaseListener;
use FOS\UserBundle\FOSUserEvents;
class FlashListener extends BaseListener {
public static function getSubscribedEvents() {
return [
FOSUserEvents::CHANGE_PASSWORD_COMPLETED => 'addSuccessFlash',
FOSUserEvents::GROUP_CREATE_COMPLETED => 'addSuccessFlash',
FOSUserEvents::GROUP_DELETE_COMPLETED => 'addSuccessFlash',
FOSUserEvents::GROUP_EDIT_COMPLETED => 'addSuccessFlash',
FOSUserEvents::PROFILE_EDIT_COMPLETED => 'addSuccessFlash',
// FOSUserEvents::REGISTRATION_COMPLETED => 'addSuccessFlash',
FOSUserEvents::RESETTING_RESET_COMPLETED => 'addSuccessFlash',
];
}
}
and that:
#src/XXXX/XXXXXBundle/Resources/config/services.yml
services:
fos_user.listener.flash:
class: XXXX\UserBundle\EventListener\FlashListener
arguments: ['@session','@translator']
tags:
- { name: kernel.event_subscriber }
但訂閱後我仍然有消息。
有人可以幫我嗎?