UPGRADE_TO_2_1 1.4KB

12345678910111213141516171819202122232425
  1. This document details all the possible changes that you should investigate when updating
  2. your project from Doctrine 2.0.x to 2.1
  3. ## Interface for EntityRepository
  4. The EntityRepository now has an interface Doctrine\Common\Persistence\ObjectRepository. This means that your classes that override EntityRepository and extend find(), findOneBy() or findBy() must be adjusted to follow this interface.
  5. ## AnnotationReader changes
  6. The annotation reader was heavily refactored between 2.0 and 2.1-RC1. In theory the operation of the new reader should be backwards compatible, but it has to be setup differently to work that way:
  7. \Doctrine\Common\Annotations\AnnotationRegistry::registerFile('/doctrine-src/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
  8. $reader = new \Doctrine\Common\Annotations\AnnotationReader();
  9. $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
  10. // new code necessary starting here
  11. $reader->setIgnoreNotImportedAnnotations(true);
  12. $reader->setEnableParsePhpImports(false);
  13. $reader = new \Doctrine\Common\Annotations\CachedReader(
  14. new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache()
  15. );
  16. This is already done inside the ``$config->newDefaultAnnotationDriver``, so everything should automatically work if you are using this method. You can verify if everything still works by executing a console command such as schema-validate that loads all metadata into memory.