Doctrine2 Two repositories on the same entity

2019-07-21 18:43发布

问题:

I don't know how to clearly explain my problem but i'll try :)

I have a project with two modules:

  • Admin
  • User

I also have two doctrine entities that cause me some troubles:

  • Shop
  • Products

My problem is that theses entities must be used by the Admin and User module, but with doctrine one Entity = one Repository (as far as i know).

How can i for having an working folders structure with doctrine like that:

-db
    -entities
        -Shop.php
        -Product.php
    -repositories
        -admin_ShopRepository.php (work with Shop entity but with an admin user)
        -admin_ProductRepository.php (work with Product entity but with an admin user)
        -user_ShopRepository.php (work with Shop entity but with an simple  user)
        -user_ProductRepository.php (work with Product entity but with an simple  user)

In fact, i would like to be able to do:

$adminShopRepo = $adminEntityManager->getRepository('Shop');

$userShopRepo = $userEntityManager->getRepository('Shop');

Thanks by advance for your answers and sorry for my bad english ! ^^