Symfony 从登录表单获取侦听器中的post参数

Symfony 从登录表单获取侦听器中的post参数,symfony,Symfony,在我的第一个Symfony2应用程序中,用户必须提交三个值才能登录。用户名、密码和域。它们位于登录表单上,并根据Firebug提交,但是应该创建令牌的侦听器无法获取值。我曾希望它能像这样简单: class UMListener implements ListenerInterface { protected $securityContext; protected $authenticationManager; public function __construct(Se

在我的第一个Symfony2应用程序中,用户必须提交三个值才能登录。用户名、密码和域。它们位于登录表单上,并根据Firebug提交,但是应该创建令牌的侦听器无法获取值。我曾希望它能像这样简单:

class UMListener implements ListenerInterface
{
    protected $securityContext;
    protected $authenticationManager;

    public function __construct(SecurityContextInterface $securityContext, AuthenticationManagerInterface $authenticationManager)
    {
        $this->securityContext = $securityContext;
        $this->authenticationManager = $authenticationManager;
    }

    public function handle(GetResponseEvent $event)
    {
        $request = $event->getRequest();
        $token->setUser($request->get('_username'));
        $token->password   = $request->get('_password');
        $token->domain    = $request->get('_domain');
    }

我已经检查过参数是_username、_password和_domain,当我打印$request时,我在任何地方都看不到它们://

当下一次谷歌搜索出现答案时,你难道不喜欢它吗。改变

$token->domain    = $request->get('_domain');

成功了

$token->domain    = $request->get('_domain', null, true);