Skip to content

Commit

Permalink
Updated UPGRADE_TO_2_1 and fixed some code
Browse files Browse the repository at this point in the history
  • Loading branch information
beberlei committed Jul 2, 2011
1 parent fea0871 commit de73b8a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
22 changes: 21 additions & 1 deletion UPGRADE_TO_2_1
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,24 @@ The annotation reader was heavily refactored between 2.0 and 2.1-RC1. In theory

## Annotation Base class or @Annotation

Beginning after 2.1-RC2 you have to either extend ``Doctrine\Common\Annotations\Annotation`` or add @Annotation to your annotations class-level docblock, otherwise you will get an exception.
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.

## Removed methods on AnnotationReader

* AnnotationReader::setAutoloadAnnotations()
* AnnotationReader::getAutoloadAnnotations()
* AnnotationReader::isAutoloadAnnotations()

## AnnotationRegistry

Autoloading through the PHP autoloader is removed from the 2.1 AnnotationReader. Instead you have to use the global AnnotationRegistry for loading purposes:

\Doctrine\Common\Annotations\AnnotationRegistry::registerFile($fileWithAnnotations);
\Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespace($namespace, $dirs = null);
\Doctrine\Common\Annotations\AnnotationRegistry::registerAutoloadNamespaces($namespaces);
\Doctrine\Common\Annotations\AnnotationRegistry::registerLoader($callable);

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.
The registerAutoloadNamespace function registers a PSR-0 compatible silent autoloader for all classes with the given namespace in the given directories.
If null is passed as directory the include path will be used.

8 changes: 3 additions & 5 deletions lib/Doctrine/Common/Annotations/AnnotationRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,9 @@ static public function loadAnnotationClass($class)
return true;
}
} else {
foreach((array)$dirs AS $dir) {
if (file_exists($dir . DIRECTORY_SEPARATOR . $file)) {
require $dir . DIRECTORY_SEPARATOR . $file;
return true;
}
if ($path = stream_resolve_include_path($file)) {
require $path;
return true;
}
}
}
Expand Down

0 comments on commit de73b8a

Please sign in to comment.