1
0
mirror of synced 2025-01-29 19:41:45 +03:00

Fixed is_subclass_of comparing an interface which brought our requirement to 5.3.9. Changed to reflection approach which still keep us at the same dependency as before.

This commit is contained in:
Guilherme Blanco 2012-07-26 15:50:51 -04:00
parent 1eaa822d2a
commit 04e6cc78cd
3 changed files with 4 additions and 5 deletions

View File

@ -593,9 +593,9 @@ class Configuration extends \Doctrine\DBAL\Configuration
*/
public function setDefaultRepositoryClassName($className)
{
$objectRepositoryClassName = 'Doctrine\Common\Persistence\ObjectRepository';
$reflectionClass = new \ReflectionClass($className);
if ($className !== $objectRepositoryClassName && ! is_subclass_of($className, $objectRepositoryClassName)) {
if ( ! $reflectionClass->implementsInterface('Doctrine\Common\Persistence\ObjectRepository')) {
throw ORMException::invalidEntityRepository($className);
}

View File

@ -152,8 +152,7 @@ class ORMException extends Exception
public static function invalidEntityRepository($className)
{
return new self("Invalid repository class '".$className."'. ".
"it must be a Doctrine\\ORM\\EntityRepository.");
return new self("Invalid repository class '".$className."'. It must be a Doctrine\Common\Persistence\ObjectRepository.");
}
public static function missingIdentifierField($className, $fieldName)

View File

@ -528,7 +528,7 @@ class EntityRepositoryTest extends \Doctrine\Tests\OrmFunctionalTestCase
/**
* @group DDC-753
* @expectedException Doctrine\ORM\ORMException
* @expectedExceptionMessage Invalid repository class 'Doctrine\Tests\Models\DDC753\DDC753InvalidRepository'. it must be a Doctrine\ORM\EntityRepository.
* @expectedExceptionMessage Invalid repository class 'Doctrine\Tests\Models\DDC753\DDC753InvalidRepository'. It must be a Doctrine\Common\Persistence\ObjectRepository.
*/
public function testSetDefaultRepositoryInvalidClassError()
{