public function setDefaultRepositoryClassName() { $this->assertSame('Doctrine\\ORM\\EntityRepository', $this->configuration->getDefaultRepositoryClassName()); $repositoryClass = 'Doctrine\\Tests\\Models\\DDC753\\DDC753CustomRepository'; $this->configuration->setDefaultRepositoryClassName($repositoryClass); $this->assertSame($repositoryClass, $this->configuration->getDefaultRepositoryClassName()); $this->setExpectedException('Doctrine\\ORM\\ORMException'); $this->configuration->setDefaultRepositoryClassName(__CLASS__); }
/** * Gets the repository for an entity class. * * @param string $entityName The name of the entity. * @return EntityRepository The repository class. */ public function getRepository($entityName) { $entityName = ltrim($entityName, '\\'); if (isset($this->repositories[$entityName])) { return $this->repositories[$entityName]; } $metadata = $this->getClassMetadata($entityName); $repositoryClassName = $metadata->customRepositoryClassName; if ($repositoryClassName === null) { $repositoryClassName = $this->config->getDefaultRepositoryClassName(); } $repository = new $repositoryClassName($this, $metadata); $this->repositories[$entityName] = $repository; return $repository; }