Search code examples
phpsymfonydoctrine-orm

Override Doctrine Annotation Driver


I have to make some changes in Doctrine\Common\Persistence\Mapping\Driver\Annotation::getAllClassNames because Doctrine use require_one and I want it to use my custom spl autoloader.

My Question is: How can I tell Doctrine to use my own code without changing Symfony's vendor folder?


Solution

  • You may be able to achieve this by setting the parameter doctrine.orm.metadata.annotation.class to the name of your class in your parameters.ini/yml/xml.

    From Doctrine/Bundle/DoctrineBundle/Resources/config/orm.xml:

     <parameter key="doctrine.orm.metadata.annotation.class">Doctrine\ORM\Mapping\Driver\AnnotationDriver</parameter>
    

    I've not tested this myself, but this is how I've overriden things like this in the past.