From ccace8cb8bbfe0ef49e336c1f4e81ba4272879ac Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Tue, 17 Jan 2012 15:39:52 +0100 Subject: [PATCH] Moving exception throwing for invalid file mappings to Doctrine\Common\Persistence\Mapping\Driver\FileDriver --- .../ORM/Mapping/Driver/AbstractFileDriver.php | 16 ---------------- lib/Doctrine/ORM/Mapping/MappingException.php | 7 +------ .../Tests/ORM/Mapping/XmlMappingDriverTest.php | 2 +- .../Tests/ORM/Mapping/YamlMappingDriverTest.php | 2 +- 4 files changed, 3 insertions(+), 24 deletions(-) diff --git a/lib/Doctrine/ORM/Mapping/Driver/AbstractFileDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AbstractFileDriver.php index 31e7e068e..1bbed0cf2 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AbstractFileDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AbstractFileDriver.php @@ -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; - } } \ No newline at end of file diff --git a/lib/Doctrine/ORM/Mapping/MappingException.php b/lib/Doctrine/ORM/Mapping/MappingException.php index 86dc5dd25..fd4e1a8ec 100644 --- a/lib/Doctrine/ORM/Mapping/MappingException.php +++ b/lib/Doctrine/ORM/Mapping/MappingException.php @@ -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."); diff --git a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php index 3106bc1d3..83e524a65 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/XmlMappingDriverTest.php @@ -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() diff --git a/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php index 08570a22c..91dd7e3bd 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/YamlMappingDriverTest.php @@ -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()