指定实体的实体经理

时间:2016-09-23 06:43:43

标签: symfony doctrine-orm configuration entitymanager

我有多个经理,其中一个的配置就像这样

doctrine:
  orm:
    entity_managers:
      support:
        connection: support
        mappings:
          APIBundle: ~

但是APIBundle中有数十个实体,我在这个管理器中只需要其中一些实体。在这种情况下应该采用什么样的正确配置?

1 个答案:

答案 0 :(得分:0)

我在学说文档中找不到与你所要求的内容相符的任何内容。

但是通过阅读the mapping part,我们可以想象一个小技巧可以通过它:

在两个不同的文件夹中定义您的实体:

APIBundle
|
--- Em1Entity
|
--- SupportEntity

然后在您的配置中,指定dir配置:

doctrine:
  orm:
    entity_managers:
      support:
        connection: support
        mappings:
          Support:
            mapping:              true
            type:                 ~
            dir:                  APIBundle\SupportEntity
            alias:                ~
            prefix:               ~
            is_bundle:            ~ 

这只是猜测,我没有亲自测试过这个黑客。