1
0
mirror of synced 2025-02-20 14:13:15 +03:00

new branch for DDC-753

This commit is contained in:
Fabio B. Silva 2011-09-08 14:36:13 -03:00
parent 2b3bee1fa4
commit 84cd22d7f7
3 changed files with 37 additions and 0 deletions

View File

@ -516,4 +516,31 @@ class Configuration extends \Doctrine\DBAL\Configuration
}
return $this->_attributes['classMetadataFactoryName'];
}
/**
* Set default repository class.
*
* @since 2.2
* @param string $className
* @throws ORMException If not implements Doctrine\Common\Persistence\ObjectRepository
*/
public function setDefaultRepositoryClassName($className)
{
if (!is_subclass_of($className, 'Doctrine\Common\Persistence\ObjectRepository')) {
throw ORMException::invalidObjectRepository($className);
}
$this->_attributes['defaultRepositoryClassName'] = $className;
}
/**
* Get default repository class.
*
* @since 2.2
* @return string
*/
public function getDefaultRepositoryClassName()
{
return isset($this->_attributes['defaultRepositoryClassName']) ?
$this->_attributes['defaultRepositoryClassName'] : 'Doctrine\ORM\EntityRepository';
}
}

View File

@ -1519,12 +1519,17 @@ class ClassMetadataInfo implements ClassMetadata
* Registers a custom repository class for the entity class.
*
* @param string $mapperClassName The class name of the custom mapper.
* @throws MappingException If not implements Doctrine\Common\Persistence\ObjectRepository
*/
public function setCustomRepositoryClass($repositoryClassName)
{
if ($repositoryClassName !== null && strpos($repositoryClassName, '\\') === false
&& strlen($this->namespace) > 0) {
$repositoryClassName = $this->namespace . '\\' . $repositoryClassName;
if (!is_subclass_of($repositoryClassName, 'Doctrine\Common\Persistence\ObjectRepository')) {
throw MappingException::invalidObjectRepository($repositoryClassName);
}
}
$this->customRepositoryClassName = $repositoryClassName;
}

View File

@ -130,4 +130,9 @@ class ORMException extends Exception
"Unknown Entity namespace alias '$entityNamespaceAlias'."
);
}
public static function invalidObjectRepository($className) {
return new self("Invalid repository class '".$className."'. ".
"it must implement Doctrine\Common\Persistence\ObjectRepository.");
}
}