I know how to override anypart of a bundle in Symfony2. I followed this
and it worked.
But what if I want to override a file in the vendor folder which is not part of a bundle.
In my specific example I need to override
vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
Is this possible? Thanks for your help
You have to tell the EntityManager which Metadata Driver to use:
<?php
$driver = new \Doctrine\ORM\Mapping\Driver\XmlDriver('/path/to/mapping/files');
$em->getConfiguration()->setMetadataDriverImpl($driver);
Instead of the default XmlDriver
, you use your extended version, eg
<?php
$driver = new \My\XmlDriver('/path/to/mapping/files');
$em->getConfiguration()->setMetadataDriverImpl($driver);
The $em
in this snippet is the EntityManager.
See http://docs.doctrine-project.org/en/latest/reference/metadata-drivers.html for further details on how to write and use your own Metadriver implementations.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.