Skip to content

Commit

Permalink
[DoctrineBundle] fixed alias support to be in sync with the latest ve…
Browse files Browse the repository at this point in the history
…rsion of Doctrine
  • Loading branch information
fabpot committed Mar 5, 2010
1 parent 60b714c commit 8ed170c
Showing 1 changed file with 3 additions and 10 deletions.
Expand Up @@ -200,6 +200,7 @@ public function ormLoad($config)
$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));
Expand All @@ -218,16 +219,7 @@ public function ormLoad($config)
{
$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)
Expand All @@ -240,6 +232,7 @@ public function ormLoad($config)
}
}
}
$ormConfigDef->addMethodCall('setEntityNamespaces', array($aliasMap));

$configuration->setDefinition('doctrine.orm.metadata_driver', $mappingDriverDef);

Expand Down

0 comments on commit 8ed170c

Please sign in to comment.