我有多个具有不同dbal连接的捆绑包,并且在映射配置中遇到问题
这是错误:
The class 'Mine\DocumentationBundle\Entity\Category' was not found in the chain configured namespaces Mine\xDb\Entity
config.yml:
doctrine:
dbal:
default_connection: x
connections:
x:
driver host port...
cms:
driver host port...
orm:
auto_generate_proxy_classes: "%kernel.debug%"
default_entity_manager: default
entity_managers:
default:
naming_strategy: doctrine.orm.naming_strategy.underscore
connection: x
mappings:
MineXDbBundle
cms:
connection: cms
mappings:
MineDocumentationBundle: ~
bin/console config:dump-reference
的输出:
---------------------------- ------------------------
Bundle name Extension alias
---------------------------- ------------------------
...
MineDocumentationBundle
MineXDbBundle mine_x_db
OrbitaleCmsBundle orbitale_cms
...
bin/console doctrine:mapping:info --em=default
的输出:
Found 75 mapped entities:
[OK] (all OK for Mine\xDB\Entity\*)...
bin/console doctrine:mapping:info --em=cms
的输出:
Found 4 mapped entities:
[OK] Mine\DocumentationBundle\Entity\Page
[OK] Mine\DocumentationBundle\Entity\Category
[OK] Orbitale\Bundle\CmsBundle\Entity\Category
[OK] Orbitale\Bundle\CmsBundle\Entity\Page
Orbitale\Bundle\CmsBundle\OrbitaleCmsBundle()
和Mine\DocumentationBundle\MineDocumentationBundle(),
都注册到AppKernel中,我用命令成功创建了表
bin/console doctrine:schema:update --force -em=cms
我知道我错过了一些东西,但我没有设法解决这个问题。
答案 0 :(得分:0)
我终于找到了真正的问题。 Orbitale Bundle控制器在此行引发了错误:
$categories = $this->get('orbitale_cms.category_repository');
意味着currrent实体经理没有定义任何CategoryEntity
。
所以我添加了一个文件来更改这个包加载的实体管理器。
<强>矿/ DocumentationBundle / Ressources /配置/ services.yml 强>
services:
orbitale_cms.page_repository:
class: Orbitale\Bundle\CmsBundle\Repository\PageRepository
factory: ['@doctrine.orm.cms_entity_manager', 'getRepository']
arguments:
- "%orbitale_cms.page_class%"
calls:
- [ 'setConfig', ['%orbitale_cms.cache%'] ]
orbitale_cms.category_repository:
class: Orbitale\Bundle\CmsBundle\Repository\CategoryRepository
factory: ['@doctrine.orm.cms_entity_manager', 'getRepository']
arguments:
- "%orbitale_cms.category_class%"
calls:
- [ 'setConfig', ['%orbitale_cms.cache%'] ]
就是这样。