~ubuntu-branches/ubuntu/wily/php-doctrine-common/wily-proposed

« back to all changes in this revision

Viewing changes to UPGRADE_TO_2_1

  • Committer: Package Import Robot
  • Author(s): David Prévot
  • Date: 2014-06-15 11:26:00 UTC
  • mfrom: (2.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20140615112600-sg4mgpwq9sfg4mre
Tags: 2.4.2-2
* Upload to unstable
* No tests if DEB_BUILD_OPTIONS contains nocheck

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
This document details all the possible changes that you should investigate when updating
 
2
your project from Doctrine Common 2.0.x to 2.1
 
3
 
 
4
## AnnotationReader changes
 
5
 
 
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
 
 
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
 
 
17
## Annotation Base class or @Annotation
 
18
 
 
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.
 
20
 
 
21
## Removed methods on AnnotationReader
 
22
 
 
23
* AnnotationReader::setAutoloadAnnotations()
 
24
* AnnotationReader::getAutoloadAnnotations()
 
25
* AnnotationReader::isAutoloadAnnotations()
 
26
 
 
27
## AnnotationRegistry
 
28
 
 
29
Autoloading through the PHP autoloader is removed from the 2.1 AnnotationReader. Instead you have to use the global AnnotationRegistry for loading purposes:
 
30
 
 
31
    \Doctrine\Common\Annotations\AnnotationRegistry::registerFile($fileWithAnnotations);
 
32
    \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace($namespace, $dirs = null);
 
33
    \Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespaces($namespaces);
 
34
    \Doctrine\Common\Annotations\AnnotationRegistry::registerLoader($callable);
 
35
 
 
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.
 
37
The registerAutoloadNamespace function registers a PSR-0 compatible silent autoloader for all classes with the given namespace in the given directories.
 
38
If null is passed as directory the include path will be used.
 
39