调用事件侦听器中的控制器/操作


Call controller/action in event listener

我想在用户登录时在后台运行一个进程。所以我在登录监听器中创建了一个进程。

这是我的密码。

public function onLogin(InteractiveLoginEvent $event)
    {
      $user = $event->getAuthenticationToken()->getUser();
      if($user)
      {
        $userid= $user->getId();
        echo $userid;
        $process = new Process('php d:wamp/www/jobologic/app/console JJJJ:RRRR'." ".$userid); 
        $process->start();
      }
    }

在后台开始处理之后。我想让用户看到网站的主页。在$process->start()函数之后我应该做什么?

如果您使用表单登录,您可以配置默认目标路径,并使用以下配置强制它:

firewalls:
    myfirewall:
        # ...
        form_login:
            # ...
            always_use_default_target_path: true
            default_target_path:            /

配置参考:http://symfony.com/doc/current/reference/configuration/security.html