Php Symfony2-在身份验证提供程序中获取EntityManager

Php Symfony2-在身份验证提供程序中获取EntityManager,php,symfony,entitymanager,Php,Symfony,Entitymanager,我已经创建了一个自定义身份验证提供程序。是否有办法在身份验证提供程序或侦听器中获取实体管理器 我知道您可以在UserProvider中获得它,但事实是,我只想在凭据正确时刷新用户(我针对windows server Active Directory进行身份验证)是的,您可以在服务定义中插入实体管理器,例如: services: wsse.security.authentication.provider: class: Acme\DemoBundle\Security\Au

我已经创建了一个自定义身份验证提供程序。是否有办法在身份验证提供程序或侦听器中获取实体管理器


我知道您可以在UserProvider中获得它,但事实是,我只想在凭据正确时刷新用户(我针对windows server Active Directory进行身份验证)

是的,您可以在服务定义中插入实体管理器,例如:

services:
    wsse.security.authentication.provider:
        class: Acme\DemoBundle\Security\Authentication\Provider\WsseProvider
        arguments: ["", "%kernel.cache_dir%/security/nonces", "@doctrine.orm.entity_manager"]
然后在WsseProvider内调整
\u构造
方法:

private $em;

public function __construct(UserProviderInterface $userProvider, $cacheDir, EntityManager $em)
{
    $this->userProvider = $userProvider;
    $this->cacheDir     = $cacheDir;
    $this->em           = $em;
}

正确的!我早该知道的。但非常感谢您的快速回答;)