ユーザーが Symfony セットアップにログインしたときに起動するイベント リスナーがあります。
私のservices.ymlには次のものがあります
...
d_user.login_listener:
class: D\UserBundle\EventListener\LoginListener
arguments: []
tags:
- { name: 'kernel.event_subscriber', event: 'security.interactive_login' }
私のログインリスナーには、次のようなものがあります。
<?php
namespace D\UserBundle\EventListener;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class LoginListener implements EventSubscriberInterface
{
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
{
echo 'user logged in';
}
public static function getSubscribedEvents()
{
return array(
// must be registered before the default Locale listener
'security.interactive_login' => array(array('onSecurityInteractiveLogin', 18))
);
}
}
私の開発サーバーでは、リダイレクトの前に「ユーザーがログインしました」というテキストが正しく表示されますが、実稼働サーバーでは、イベントが発生せずにログインするだけです。後でこれを変更して、ユーザー ログイン時にセッション変数を設定します。呼び出されたメソッドを取得するだけです。
何かアドバイス?実稼働環境で prod と dev のキャッシュをクリアしようとしましたが、役に立ちませんでした。