[DoctrineBundle] Integrating the new Doctrine 2.0 entity alias feature for the query language

This commit is contained in:
Jonathan H. Wage 2010-02-26 13:12:46 -05:00 committed by Fabien Potencier
parent 42ad9b7c72
commit 47aee04459
1 changed files with 11 additions and 0 deletions

View File

@ -213,6 +213,17 @@ class DoctrineExtension extends LoaderExtension
elseif (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Entities'))
{
$type = 'annotation';
$reader = new \Doctrine\Common\Annotations\AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\');
$annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, $dir);
$classNames = $annotationDriver->getAllClassNames();
foreach ($classNames as $className)
{
$alias = substr_replace($className, '', 0, strpos($className, '\\') + 1);
$alias = str_replace('\Entities\\', '\\', $alias);
$ormConfigDef->addMethodCall('addEntityAlias', array($className, $alias));
}
}
else
{