在我的第一个 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 时,我在任何地方都看不到它们:/