Resolve Target Entity with multiple entity managers

Viewed 1492

Is it possible to resolve a target entity over multiple entity managers?

I have a class person (in a re-usable bundle):

/**
 *
 * @ORM\Entity
 * @ORM\Table(name="my_vendor_person")
 */
class Person
{ 
    /**
     * Unique Id
     *
     * @var integer $id
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * First Name
     *
     * @var string $name
     *
     * @ORM\Column(name="first_name", type="string", length=32)
     */
    protected $firstName;
    // etc...

And a class user (in my main application):

/**
 * @ORM\Entity
 *
 * @ORM\Table(name="my_financial_user")
 *
 */
class User extends BaseUser
{

    /**
     * @ORM\OneToOne(targetEntity="My\FinancialBundle\Model\PersonInterface")
     * @var PersonInterface
     */
    protected $person;

Basically I want to couple the user to a person from the re-usable bundle.

I had set resolve target entity option in doctrine's configuration which I thought it allows me to do this:

doctrine:
  orm:
      auto_generate_proxy_classes: "%kernel.debug%"
      default_entity_manager: default
      resolve_target_entities:
          My\FinanceBundle\Model\PersonInterface: My\VendorBundle\Entity\Person
      entity_managers:
          default:
              naming_strategy: doctrine.orm.naming_strategy.underscore
              connection: default
              mappings:
                  MyFinanceBundle: ~
          second:
              naming_strategy: doctrine.orm.naming_strategy.underscore
              auto_mapping: false
              connection: second
              mappings:
                  MyVendorBundle: ~
                  MyVendorUserBundle: ~

Also, the user class in the main bundle, extends a base user in the vendor bundle. The user class of course is maintained, in the main-applications db.

With this configuration it gives me an error.

[Doctrine\Common\Persistence\Mapping\MappingException]                                                                                       
The class 'My\VendorBundle\Entity\Person' was not found in the chain configured namespaces My\FinanceBundle\Entity, FOS\UserBundle\Model 

Does anyone know how to solve this?

1 Answers
Related