我知道如何在Symfony2中覆盖bundle的anypart。我跟着this
并且有效。
但是,如果我想覆盖供应商文件夹中不属于捆绑包的文件,该怎么办?
在我的具体示例中,我需要覆盖
vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
这可能吗?谢谢你的帮助
答案 0 :(得分:1)
您必须告诉EntityManager使用哪个元数据驱动程序:
<?php
$driver = new \Doctrine\ORM\Mapping\Driver\XmlDriver('/path/to/mapping/files');
$em->getConfiguration()->setMetadataDriverImpl($driver);
而不是默认XmlDriver
,您使用扩展版本,例如
<?php
$driver = new \My\XmlDriver('/path/to/mapping/files');
$em->getConfiguration()->setMetadataDriverImpl($driver);
此代码段中的$em
是EntityManager。
有关如何编写和使用自己的Metadriver实现的更多详细信息,请参阅http://docs.doctrine-project.org/en/latest/reference/metadata-drivers.html。