[DoctrineBridge] [PropertyInfo] Catch Doctrine\ORM\Mapping\MappingException
This commit is contained in:
parent
b1a7949b36
commit
ceded10f67
@ -14,6 +14,7 @@ namespace Symfony\Bridge\Doctrine\PropertyInfo;
|
||||
use Doctrine\Common\Persistence\Mapping\ClassMetadataFactory;
|
||||
use Doctrine\Common\Persistence\Mapping\MappingException;
|
||||
use Doctrine\ORM\Mapping\ClassMetadataInfo;
|
||||
use Doctrine\ORM\Mapping\MappingException as OrmMappingException;
|
||||
use Symfony\Component\PropertyInfo\PropertyListExtractorInterface;
|
||||
use Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface;
|
||||
use Symfony\Component\PropertyInfo\Type;
|
||||
@ -44,6 +45,8 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
|
||||
$metadata = $this->classMetadataFactory->getMetadataFor($class);
|
||||
} catch (MappingException $exception) {
|
||||
return;
|
||||
} catch (OrmMappingException $exception) {
|
||||
return;
|
||||
}
|
||||
|
||||
return array_merge($metadata->getFieldNames(), $metadata->getAssociationNames());
|
||||
@ -58,6 +61,8 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
|
||||
$metadata = $this->classMetadataFactory->getMetadataFor($class);
|
||||
} catch (MappingException $exception) {
|
||||
return;
|
||||
} catch (OrmMappingException $exception) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($metadata->hasAssociation($property)) {
|
||||
|
@ -81,4 +81,14 @@ class DoctrineExtractorTest extends \PHPUnit_Framework_TestCase
|
||||
array('notMapped', null),
|
||||
);
|
||||
}
|
||||
|
||||
public function testGetPropertiesCatchException()
|
||||
{
|
||||
$this->assertNull($this->extractor->getProperties('Not\Exist'));
|
||||
}
|
||||
|
||||
public function testGetTypesCatchException()
|
||||
{
|
||||
$this->assertNull($this->extractor->getTypes('Not\Exist', 'baz'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user