Skip to content

Commit

Permalink
[DoctrineBundle] fixed the overridding of an Entity
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Mar 10, 2010
1 parent dad7552 commit fff1334
Showing 1 changed file with 24 additions and 22 deletions.
Expand Up @@ -201,35 +201,37 @@ public function ormLoad($config)
$bundleEntityMappings = array();
$bundleDirs = $this->bundleDirs;
$aliasMap = array();
foreach ($this->bundles as $className)
foreach (array_reverse($this->bundles) as $className)
{
$tmp = dirname(str_replace('\\', '/', $className));
$namespace = str_replace('/', '\\', dirname($tmp));
$class = basename($tmp);

if (isset($bundleDirs[$namespace]))
{
$type = false;
if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Resources/config/doctrine/metadata'))
{
$type = $this->detectMappingType($dir);
}

if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Entities'))
{
$type = 'annotation';

$aliasMap[$class] = $namespace.'\\'.$class.'\\Entities';
}

if (false !== $type)
{
$mappingDriverDef->addMethodCall('addDriver', array(
new Reference(sprintf('doctrine.orm.metadata_driver.%s', $type)),
$namespace.'\\'.$class.'\\Entities'
)
);
}
continue;
}

$type = false;
if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Resources/config/doctrine/metadata'))
{
$type = $this->detectMappingType($dir);
}

if (is_dir($dir = $bundleDirs[$namespace].'/'.$class.'/Entities'))
{
$type = 'annotation';

$aliasMap[$class] = $namespace.'\\'.$class.'\\Entities';
}

if (false !== $type)
{
$mappingDriverDef->addMethodCall('addDriver', array(
new Reference(sprintf('doctrine.orm.metadata_driver.%s', $type)),
$namespace.'\\'.$class.'\\Entities'
)
);
}
}
$ormConfigDef->addMethodCall('setEntityNamespaces', array($aliasMap));
Expand Down

0 comments on commit fff1334

Please sign in to comment.