Symfony 2.6:如何获取当前用于登录的提供商?
Symfony 2.6 : How to get the current provider used to log in?
我的 SF2.6 项目遇到问题。我有两种用户(客户,员工)所以我使用多个实体提供者
providers:
chain_provider:
chain:
providers: [employee, client]
employee:
entity: { class: SpeedDev\MyprojectsBundle\Entity\Employee, property: emailEmp }
client:
entity: { class: SpeedDev\MyprojectsBundle\Entity\Client, property: contactemailClient }
我可以以客户或员工的身份登录我的应用程序,然后 SF 会在右侧 table 检查凭据。
我的问题是我需要检索员工或客户 sf 之间的哪个实体用作提供者,所以我知道在 $this->getUser()->getIdEmp() 或 $this- 之间使用哪个实体的函数>getUser()->getIdClient()
提前致谢
您可以检查一下您的 $this->getUser()
是否是您想要的 instanceof
实体:
if ($this->getUser() instanceof SpeedDev\MyprojectsBundle\Entity\Employee) {
// this is employee
}
我的 SF2.6 项目遇到问题。我有两种用户(客户,员工)所以我使用多个实体提供者
providers:
chain_provider:
chain:
providers: [employee, client]
employee:
entity: { class: SpeedDev\MyprojectsBundle\Entity\Employee, property: emailEmp }
client:
entity: { class: SpeedDev\MyprojectsBundle\Entity\Client, property: contactemailClient }
我可以以客户或员工的身份登录我的应用程序,然后 SF 会在右侧 table 检查凭据。
我的问题是我需要检索员工或客户 sf 之间的哪个实体用作提供者,所以我知道在 $this->getUser()->getIdEmp() 或 $this- 之间使用哪个实体的函数>getUser()->getIdClient()
提前致谢
您可以检查一下您的 $this->getUser()
是否是您想要的 instanceof
实体:
if ($this->getUser() instanceof SpeedDev\MyprojectsBundle\Entity\Employee) {
// this is employee
}