DefaultRepositoryFactory: single repository for aliased entities
This commit is contained in:
parent
5ff67c92ee
commit
a665cb0229
@ -43,13 +43,15 @@ class DefaultRepositoryFactory implements RepositoryFactory
|
|||||||
{
|
{
|
||||||
$entityName = ltrim($entityName, '\\');
|
$entityName = ltrim($entityName, '\\');
|
||||||
|
|
||||||
if (isset($this->repositoryList[$entityName])) {
|
$class = $entityManager->getClassMetadata($entityName)->getName();
|
||||||
return $this->repositoryList[$entityName];
|
|
||||||
|
if (isset($this->repositoryList[$class])) {
|
||||||
|
return $this->repositoryList[$class];
|
||||||
}
|
}
|
||||||
|
|
||||||
$repository = $this->createRepository($entityManager, $entityName);
|
$repository = $this->createRepository($entityManager, $entityName);
|
||||||
|
|
||||||
$this->repositoryList[$entityName] = $repository;
|
$this->repositoryList[$class] = $repository;
|
||||||
|
|
||||||
return $repository;
|
return $repository;
|
||||||
}
|
}
|
||||||
|
@ -611,6 +611,23 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
|||||||
$this->_em->getConfiguration()->setDefaultRepositoryClassName("Doctrine\Tests\Models\DDC753\DDC753InvalidRepository");
|
$this->_em->getConfiguration()->setDefaultRepositoryClassName("Doctrine\Tests\Models\DDC753\DDC753InvalidRepository");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testSingleRepositoryInstanceForAnEntity()
|
||||||
|
{
|
||||||
|
$config = $this->_em->getConfiguration();
|
||||||
|
$config->addEntityNamespace('Aliased', 'Doctrine\Tests\Models\CMS');
|
||||||
|
$config->addEntityNamespace('AliasedAgain', 'Doctrine\Tests\Models\CMS');
|
||||||
|
|
||||||
|
$this->assertSame(
|
||||||
|
$this->_em->getRepository('Doctrine\Tests\Models\CMS\CmsUser'),
|
||||||
|
$this->_em->getRepository('Aliased:CmsUser')
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertSame(
|
||||||
|
$this->_em->getRepository('Aliased:CmsUser'),
|
||||||
|
$this->_em->getRepository('AliasedAgain:CmsUser')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @group DDC-1376
|
* @group DDC-1376
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user