addEntityAlias() public method

For example ->addEntityAlias('user', 'Project\Bundle\Module\Entity\User') would allow ->getRepository('user')
public addEntityAlias ( string $alias, string $namespace )
$alias string
$namespace string
示例#1
0
 public function testGetRepositoryWithAliases()
 {
     $app = $this->getApp();
     $em = new EntityManager($app['db'], $app['dispatcher'], $app['storage.metadata']);
     $customRepoClass = 'Bolt\\Tests\\Storage\\Mock\\TestRepository';
     $em->setRepository('Bolt\\Storage\\Entity\\Users', $customRepoClass);
     $em->addEntityAlias('test', 'Bolt\\Storage\\Entity\\Users');
     $repo = $em->getRepository('test');
     $this->assertInstanceOf('Bolt\\Tests\\Storage\\Mock\\TestRepository', $repo);
 }