Chris@0
|
1 This document details all the possible changes that you should investigate when updating
|
Chris@0
|
2 your project from Doctrine Common 2.0.x to 2.1
|
Chris@0
|
3
|
Chris@0
|
4 ## AnnotationReader changes
|
Chris@0
|
5
|
Chris@0
|
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:
|
Chris@0
|
7
|
Chris@0
|
8 $reader = new \Doctrine\Common\Annotations\AnnotationReader();
|
Chris@0
|
9 $reader->setDefaultAnnotationNamespace('Doctrine\ORM\Mapping\\');
|
Chris@0
|
10 // new code necessary starting here
|
Chris@0
|
11 $reader->setIgnoreNotImportedAnnotations(true);
|
Chris@0
|
12 $reader->setEnableParsePhpImports(false);
|
Chris@0
|
13 $reader = new \Doctrine\Common\Annotations\CachedReader(
|
Chris@0
|
14 new \Doctrine\Common\Annotations\IndexedReader($reader), new ArrayCache()
|
Chris@0
|
15 );
|
Chris@0
|
16
|
Chris@0
|
17 ## Annotation Base class or @Annotation
|
Chris@0
|
18
|
Chris@0
|
19 Beginning after 2.1-RC2 you have to either extend ``Doctrine\Common\Annotations\Annotation`` or add @Annotation to your annotations class-level docblock, otherwise the class will simply be ignored.
|
Chris@0
|
20
|
Chris@0
|
21 ## Removed methods on AnnotationReader
|
Chris@0
|
22
|
Chris@0
|
23 * AnnotationReader::setAutoloadAnnotations()
|
Chris@0
|
24 * AnnotationReader::getAutoloadAnnotations()
|
Chris@0
|
25 * AnnotationReader::isAutoloadAnnotations()
|
Chris@0
|
26
|
Chris@0
|
27 ## AnnotationRegistry
|
Chris@0
|
28
|
Chris@0
|
29 Autoloading through the PHP autoloader is removed from the 2.1 AnnotationReader. Instead you have to use the global AnnotationRegistry for loading purposes:
|
Chris@0
|
30
|
Chris@0
|
31 \Doctrine\Common\Annotations\AnnotationRegistry::registerFile($fileWithAnnotations);
|
Chris@0
|
32 \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace($namespace, $dirs = null);
|
Chris@0
|
33 \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespaces($namespaces);
|
Chris@0
|
34 \Doctrine\Common\Annotations\AnnotationRegistry::registerLoader($callable);
|
Chris@0
|
35
|
Chris@0
|
36 The $callable for registering a loader accepts a class as first and only parameter and must try to silently autoload it. On success true has to be returned.
|
Chris@0
|
37 The registerAutoloadNamespace function registers a PSR-0 compatible silent autoloader for all classes with the given namespace in the given directories.
|
Chris@0
|
38 If null is passed as directory the include path will be used.
|
Chris@0
|
39
|