我有一个自定义Bundle,我们称它为FooBarBundle
。
现在,从自定义扩展中,我想添加以下内容:
# Doctrine Configuration
doctrine:
orm:
mappings:
FooBarBundle : ~
我相信这应该是不可能的,但我找不到任何证据证明一个bundle不能在另一个bundle的配置选项之前添加。
我不确定这是否相关:http://symfony.com/doc/current/bundles/prepend_extension.html
理想情况下,我希望一堆我自己的捆绑包添加自己的学说映射,而不是依赖于更新配置。使用每个Bundle时。
是的,您可以为每个包执行此操作,而无需更新config.yml
文件:
namespace FooBarBundle'DependencyInjection;
// ...
class FooBarExtension extends Extension implements PrependExtensionInterface
{
//...
public function prepend(ContainerBuilder $container)
{
$container->loadFromExtension('doctrine', array(
'orm' => array(
'mappings' => array(
'FooBarBundle' => null,
)
),
));
}
}