【发布时间】:2017-08-09 18:36:02
【问题描述】:
我正在尝试覆盖 LastLoginListener 以向其添加功能。
我正在尝试按照here 的描述进行操作 好像
在 AppBundle\DependencyInjection\OverrideServiceCompilerPass.php 中
<?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);
}
services.yml
services:
app.login_listener:
class: AppBundle\EventListener\LastLoginListener
arguments: []
tags:
- { name: kernel.event_subscriber }
侦听器本身是从包中复制的。
自动加载器预期类“AppBundle\DependencyInjection\OverrideServiceCompilerPass”将在文件“/vendor/composer/../../src/AppBundle/DependencyInjection/OverrideServiceCompilerPass.php”中定义。找到文件但类不在其中,类名或命名空间可能有错字。 在 DebugClassLoader.php(第 261 行)
我的目标是使用监听器添加上次登录的 IP 地址,但我需要创建另一个以添加角色和注册日期 我正在尝试以“正确的方式”而不是做一些骇人听闻的事情
【问题讨论】:
标签: symfony fosuserbundle