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

时间:2012-09-17 04:20:31

标签: symfony

在我的第一个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,当我print_r $ request时我无法在任何地方看到它们:/

1 个答案:

答案 0 :(得分:0)

当你下一次谷歌搜索提出答案时,你是否只是讨厌它?改变

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

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

做了这个伎俩