Moving exception throwing for invalid file mappings to Doctrine\Common\Persistence\Mapping\Driver\FileDriver
This commit is contained in:
parent
03fb734de8
commit
ccace8cb8b
4 changed files with 3 additions and 24 deletions
|
@ -41,20 +41,4 @@ use Doctrine\Common\Persistence\Mapping\Driver\FileLocator;
|
|||
*/
|
||||
abstract class AbstractFileDriver extends FileDriver implements Driver
|
||||
{
|
||||
/**
|
||||
* Get the element of schema meta data for the class from the mapping file.
|
||||
* This will lazily load the mapping file if it is not loaded yet
|
||||
*
|
||||
* @return array $element The element of schema meta data
|
||||
* @throws MappingException
|
||||
* @todo move behavior to FileDriver
|
||||
*/
|
||||
public function getElement($className)
|
||||
{
|
||||
$result = parent::getElement($className);
|
||||
if($result === null) {
|
||||
throw MappingException::invalidMappingFile($className, str_replace('\\', '.', $className) . $this->locator->getFileExtension());
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
|
@ -78,11 +78,6 @@ class MappingException extends \Doctrine\ORM\ORMException
|
|||
return new self("No mapping file found named '$fileName' for class '$entityName'.");
|
||||
}
|
||||
|
||||
public static function invalidMappingFile($entityName, $fileName)
|
||||
{
|
||||
return new self("Invalid mapping file '$fileName' for class '$entityName'.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception for invalid property name override.
|
||||
*
|
||||
|
@ -144,7 +139,7 @@ class MappingException extends \Doctrine\ORM\ORMException
|
|||
{
|
||||
return new self('Result set mapping named "'.$resultName.'" in "'.$entity.' requires a field name.');
|
||||
}
|
||||
|
||||
|
||||
public static function nameIsMandatoryForSqlResultSetMapping($className)
|
||||
{
|
||||
return new self("Result set mapping name on entity class '$className' is not defined.");
|
||||
|
|
|
@ -55,7 +55,7 @@ class XmlMappingDriverTest extends AbstractMappingDriverTest
|
|||
/**
|
||||
* @group DDC-1468
|
||||
*
|
||||
* @expectedException Doctrine\ORM\Mapping\MappingException
|
||||
* @expectedException Doctrine\Common\Persistence\Mapping\MappingException
|
||||
* @expectedExceptionMessage Invalid mapping file 'Doctrine.Tests.Models.Generic.SerializationModel.dcm.xml' for class 'Doctrine\Tests\Models\Generic\SerializationModel'.
|
||||
*/
|
||||
public function testInvalidMappingFileException()
|
||||
|
|
|
@ -46,7 +46,7 @@ class YamlMappingDriverTest extends AbstractMappingDriverTest
|
|||
/**
|
||||
* @group DDC-1468
|
||||
*
|
||||
* @expectedException Doctrine\ORM\Mapping\MappingException
|
||||
* @expectedException Doctrine\Common\Persistence\Mapping\MappingException
|
||||
* @expectedExceptionMessage Invalid mapping file 'Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml' for class 'Doctrine\Tests\Models\Generic\SerializationModel'.
|
||||
*/
|
||||
public function testInvalidMappingFileException()
|
||||
|
|
Loading…
Add table
Reference in a new issue