LastLoginListenerをオーバーライドして機能を追加しようとしています。Fosuserbundleはイベントリスナーをオーバーライドします
私は、here を説明したように、リスナー自身があるservices.yml
services:
app.login_listener:
class: AppBundle\EventListener\LastLoginListener
arguments: []
tags:
- { name: kernel.event_subscriber }
<?php
namespace AppBundle\DependencyInjection\Compiler;
use AppBundle\EventListener\LastLoginListener;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class OverrideServiceCompilerPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
$definition = $container->getDefinition('"fos_user.security.interactive_login_listener');
$definition->setClass(LastLoginListener::class);
}
AppBundle \依存性の注入\ OverrideServiceCompilerPass.phpで
を思わそれをやろうとしているメートルバンドルからコピーされます。
"/vendor/composer/../../src/AppBundle/DependencyInjection/OverrideServiceCompilerPass.php"ファイルでオートローダが期待するクラス "AppBundle \ DependencyInjection \ OverrideServiceCompilerPass"を定義します。ファイルが見つかりましたが、クラスがそれに含まれていなかった、クラス名または名前空間はおそらくタイプミスを持っています。 DebugClassLoader.phpで (ライン261)
私の目標は、リスナーとの最後のログインのIPアドレスを追加することですが、私は私がしようとしている役割と登録日 を追加するために別のものを作成する必要があります何かをハッキングするのではなく、正しい方法で行うこと
私はこれを今動作しているイベントリスナーでやっていますが、サービスをオーバーライドするためのコンパイラパスが必要ではありません。デフォルトのリスナーの –
申し訳ありませんが、私のコメントを編集できません。それを解決策として投稿してください。 –