我得到了多个具有不同数据库连接的捆绑包,并在映射配置中遇到了问题。
这是错误:
The class 'MineDocumentationBundleEntityCategory' was not found in the chain configured namespaces MinexDbEntity
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 MinexDBEntity*)...
bin/console doctrine:mapping:info --em=cms
的输出:
Found 4 mapped entities:
[OK] MineDocumentationBundleEntityPage
[OK] MineDocumentationBundleEntityCategory
[OK] OrbitaleBundleCmsBundleEntityCategory
[OK] OrbitaleBundleCmsBundleEntityPage
OrbitaleBundleCmsBundleOrbitaleCmsBundle()
和 MineDocumentationBundleMineDocumentationBundle(),
都是 AppKernel 的注册者,我使用命令成功创建了表 bin/console doctrine:schema:update --force -em=cms
我知道我错过了一些东西,但我没有设法解决这个问题。
我终于找到了真正的问题。错误被抛出在轨道束控制器的这一行:
$categories = $this->get('orbitale_cms.category_repository');
这意味着当前实体管理器没有定义任何CategoryEntity
。所以我添加了一个文件来更改此捆绑包加载的实体管理器。
Mine/DocumentationBundle/Ressources/config/services.yml
services:
orbitale_cms.page_repository:
class: OrbitaleBundleCmsBundleRepositoryPageRepository
factory: ['@doctrine.orm.cms_entity_manager', 'getRepository']
arguments:
- "%orbitale_cms.page_class%"
calls:
- [ 'setConfig', ['%orbitale_cms.cache%'] ]
orbitale_cms.category_repository:
class: OrbitaleBundleCmsBundleRepositoryCategoryRepository
factory: ['@doctrine.orm.cms_entity_manager', 'getRepository']
arguments:
- "%orbitale_cms.category_class%"
calls:
- [ 'setConfig', ['%orbitale_cms.cache%'] ]
就是这样。