首页 > 解决方案 > 如何映射到从实体中的内存提供的用户

问题描述

我正在设置一个实体,我需要存储与实体一起操作的用户。问题是用户不是从数据库中提供的,而是从 security.yml 的内存中提供的。

安全.yml

encoders:
     Symfony\Component\Security\Core\User\User:
      algorithm: bcrypt
      cost: 15
     UserBundle\Entity\Customer:
      algorithm: bcrypt
      cost: 15
     providers:
      chain_provider:
       chain:
        providers: [admins_load_from_memory, customers_load_from_db]
      admins_load_from_memory:
       memory:
        users:
         achref:
          password:...
          roles: 'ROLE_ADMIN'
      customers_load_from_db:
       entity: { class: UserBundle\Entity\Customer, property: email }

/**
* @ORM\ManyToOne(targetEntity="Symfony\Component\Security\Core\User\User")
*/
private $treatedBy; 

                                                                                                                                   
  

当我尝试更新数据库时,出现此错误:

In MappingException.php line 22:
                                                                                                                                             
  The class 'Symfony\Component\Security\Core\User\User' was not found in the chain configured namespaces AppBundle\Entity, UserBundle\Entit  
  y  

标签: symfonydoctrine-orm

解决方案


推荐阅读