我知道如何覆盖 Symfony2 中捆绑包的任何部分。我跟着这个
它奏效了。
但是,如果我想覆盖 vendor 文件夹中不属于捆绑包的文件怎么办。
在我的具体示例中,我需要覆盖
vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
这可能吗?谢谢你的帮助
您必须告诉 EntityManager 使用哪个元数据驱动程序:
<?php
$driver = new \Doctrine\ORM\Mapping\Driver\XmlDriver('/path/to/mapping/files');
$em->getConfiguration()->setMetadataDriverImpl($driver);
而不是 default 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 。