Symfony\Bundle\DoctrineBundle\Registry::getRepository PHP Method

getRepository() public method

Gets the EntityRepository for an entity.
public getRepository ( string $entityName, $entityManagerName = null ) : Doctrine\ORM\EntityRepository
$entityName string The name of the entity.
return Doctrine\ORM\EntityRepository
    public function getRepository($entityName, $entityManagerName = null)
    {
        return $this->getEntityManager($entityManagerName)->getRepository($entityName);
    }

Usage Example

 /**
  * Return de Repository
  *
  * @return Doctrine\ORM\EntityRepository
  */
 public function getRepository()
 {
     if (null === $this->generator) {
         throw new \Exception('Can\'t instatiate a Doctrine Repository without Generator Class');
     } else {
         return $this->doctrineRegistry->getRepository($this->generator->model);
     }
 }