new branch for DDC-753
This commit is contained in:
parent
2b3bee1fa4
commit
84cd22d7f7
@ -516,4 +516,31 @@ class Configuration extends \Doctrine\DBAL\Configuration
|
|||||||
}
|
}
|
||||||
return $this->_attributes['classMetadataFactoryName'];
|
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';
|
||||||
|
}
|
||||||
}
|
}
|
@ -1519,12 +1519,17 @@ class ClassMetadataInfo implements ClassMetadata
|
|||||||
* Registers a custom repository class for the entity class.
|
* Registers a custom repository class for the entity class.
|
||||||
*
|
*
|
||||||
* @param string $mapperClassName The class name of the custom mapper.
|
* @param string $mapperClassName The class name of the custom mapper.
|
||||||
|
* @throws MappingException If not implements Doctrine\Common\Persistence\ObjectRepository
|
||||||
*/
|
*/
|
||||||
public function setCustomRepositoryClass($repositoryClassName)
|
public function setCustomRepositoryClass($repositoryClassName)
|
||||||
{
|
{
|
||||||
if ($repositoryClassName !== null && strpos($repositoryClassName, '\\') === false
|
if ($repositoryClassName !== null && strpos($repositoryClassName, '\\') === false
|
||||||
&& strlen($this->namespace) > 0) {
|
&& strlen($this->namespace) > 0) {
|
||||||
$repositoryClassName = $this->namespace . '\\' . $repositoryClassName;
|
$repositoryClassName = $this->namespace . '\\' . $repositoryClassName;
|
||||||
|
|
||||||
|
if (!is_subclass_of($repositoryClassName, 'Doctrine\Common\Persistence\ObjectRepository')) {
|
||||||
|
throw MappingException::invalidObjectRepository($repositoryClassName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$this->customRepositoryClassName = $repositoryClassName;
|
$this->customRepositoryClassName = $repositoryClassName;
|
||||||
}
|
}
|
||||||
|
@ -130,4 +130,9 @@ class ORMException extends Exception
|
|||||||
"Unknown Entity namespace alias '$entityNamespaceAlias'."
|
"Unknown Entity namespace alias '$entityNamespaceAlias'."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function invalidObjectRepository($className) {
|
||||||
|
return new self("Invalid repository class '".$className."'. ".
|
||||||
|
"it must implement Doctrine\Common\Persistence\ObjectRepository.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user