[DoctrineBundle] fixed alias support to be in sync with the latest version of Doctrine
This commit is contained in:
parent
60b714c2d3
commit
8ed170c726
|
@ -200,6 +200,7 @@ class DoctrineExtension extends LoaderExtension
|
|||
$mappingDriverDef = new Definition('Doctrine\ORM\Mapping\Driver\DriverChain');
|
||||
$bundleEntityMappings = array();
|
||||
$bundleDirs = $this->bundleDirs;
|
||||
$aliasMap = array();
|
||||
foreach ($this->bundles as $className)
|
||||
{
|
||||
$tmp = dirname(str_replace('\\', '/', $className));
|
||||
|
@ -218,16 +219,7 @@ class DoctrineExtension extends LoaderExtension
|
|||
{
|
||||
$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));
|
||||
}
|
||||
$aliasMap[$class] = $namespace.'\\'.$class.'\\Entities';
|
||||
}
|
||||
|
||||
if (false !== $type)
|
||||
|
@ -240,6 +232,7 @@ class DoctrineExtension extends LoaderExtension
|
|||
}
|
||||
}
|
||||
}
|
||||
$ormConfigDef->addMethodCall('setEntityNamespaces', array($aliasMap));
|
||||
|
||||
$configuration->setDefinition('doctrine.orm.metadata_driver', $mappingDriverDef);
|
||||
|
||||
|
|
Reference in New Issue