From c988a99d55aad58dc221ab299550a5de2348a393 Mon Sep 17 00:00:00 2001 From: "Jonathan H. Wage" Date: Wed, 16 Feb 2011 10:06:39 -0600 Subject: [PATCH] Removing old Driver interface in favor of the new one in Common\Persistence. Also changed to use fully qualified class name for interfaces in common to avoid weird aliases. --- lib/Doctrine/ORM/Configuration.php | 2 +- .../ORM/Mapping/ClassMetadataFactory.php | 5 +- .../ORM/Mapping/ClassMetadataInfo.php | 3 +- .../ORM/Mapping/Driver/AbstractFileDriver.php | 1 + .../ORM/Mapping/Driver/AnnotationDriver.php | 5 +- .../ORM/Mapping/Driver/DatabaseDriver.php | 5 +- lib/Doctrine/ORM/Mapping/Driver/Driver.php | 59 ------------------- .../ORM/Mapping/Driver/DriverChain.php | 8 +-- lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php | 5 +- .../ORM/Mapping/Driver/StaticPHPDriver.php | 5 +- lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php | 5 +- .../ORM/Mapping/Driver/YamlDriver.php | 5 +- lib/vendor/doctrine-common | 2 +- .../Tests/Mocks/MetadataDriverMock.php | 4 +- .../Tests/ORM/Mapping/DriverChainTest.php | 10 ++-- 15 files changed, 35 insertions(+), 89 deletions(-) delete mode 100644 lib/Doctrine/ORM/Mapping/Driver/Driver.php diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index 0bc206d27..80b44801d 100644 --- a/lib/Doctrine/ORM/Configuration.php +++ b/lib/Doctrine/ORM/Configuration.php @@ -20,7 +20,7 @@ namespace Doctrine\ORM; use Doctrine\Common\Cache\Cache, - Doctrine\ORM\Mapping\Driver\Driver; + Doctrine\Common\Persistence\Mapping\Driver; /** * Configuration container for all configuration options of Doctrine. diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php index 571df0eb7..cfa35fa27 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -23,8 +23,7 @@ use ReflectionException, Doctrine\ORM\ORMException, Doctrine\ORM\EntityManager, Doctrine\DBAL\Platforms, - Doctrine\ORM\Events, - Doctrine\Common\Persistence\Mapping\ClassMetadataFactory as ClassMetadataFactoryInterface; + Doctrine\ORM\Events; /** * The ClassMetadataFactory is used to create ClassMetadata objects that contain all the @@ -37,7 +36,7 @@ use ReflectionException, * @author Jonathan Wage * @author Roman Borschel */ -class ClassMetadataFactory implements ClassMetadataFactoryInterface +class ClassMetadataFactory implements \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory { /** * @var EntityManager diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index b482b1c5e..e94114fea 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -19,7 +19,6 @@ namespace Doctrine\ORM\Mapping; -use Doctrine\Common\Persistence\Mapping\ClassMetadata; use ReflectionClass; /** @@ -40,7 +39,7 @@ use ReflectionClass; * @author Jonathan H. Wage * @since 2.0 */ -class ClassMetadataInfo implements ClassMetadata +class ClassMetadataInfo implements \Doctrine\Common\Persistence\Mapping\ClassMetadata { /* The inheritance mapping types */ /** diff --git a/lib/Doctrine/ORM/Mapping/Driver/AbstractFileDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AbstractFileDriver.php index 457b7cda7..b23f1620f 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AbstractFileDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AbstractFileDriver.php @@ -22,6 +22,7 @@ namespace Doctrine\ORM\Mapping\Driver; use Doctrine\ORM\Mapping\MappingException; +use Doctrine\Common\Persistence\Mapping\Driver; /** * Base driver for file-based metadata drivers. diff --git a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php index 9eb83c2b8..568c48dea 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php @@ -22,7 +22,8 @@ namespace Doctrine\ORM\Mapping\Driver; use Doctrine\Common\Cache\ArrayCache, Doctrine\Common\Annotations\AnnotationReader, Doctrine\ORM\Mapping\ClassMetadataInfo, - Doctrine\ORM\Mapping\MappingException; + Doctrine\ORM\Mapping\MappingException, + Doctrine\Common\Persistence\Mapping\Driver; require __DIR__ . '/DoctrineAnnotations.php'; @@ -122,7 +123,7 @@ class AnnotationDriver implements Driver /** * {@inheritdoc} */ - public function loadMetadataForClass($className, ClassMetadataInfo $metadata) + public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata) { $class = $metadata->getReflectionClass(); diff --git a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php index 0dc6a05e0..ae6886fc6 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php @@ -25,7 +25,8 @@ use Doctrine\Common\Cache\ArrayCache, Doctrine\DBAL\Schema\SchemaException, Doctrine\ORM\Mapping\ClassMetadataInfo, Doctrine\ORM\Mapping\MappingException, - Doctrine\Common\Util\Inflector; + Doctrine\Common\Util\Inflector, + Doctrine\Common\Persistence\Mapping\Driver; /** * The DatabaseDriver reverse engineers the mapping metadata from a database. @@ -114,7 +115,7 @@ class DatabaseDriver implements Driver /** * {@inheritdoc} */ - public function loadMetadataForClass($className, ClassMetadataInfo $metadata) + public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata) { $this->reverseEngineerMappingFromDatabase(); diff --git a/lib/Doctrine/ORM/Mapping/Driver/Driver.php b/lib/Doctrine/ORM/Mapping/Driver/Driver.php deleted file mode 100644 index b6cfe36b4..000000000 --- a/lib/Doctrine/ORM/Mapping/Driver/Driver.php +++ /dev/null @@ -1,59 +0,0 @@ -. - */ - -namespace Doctrine\ORM\Mapping\Driver; - -use Doctrine\ORM\Mapping\ClassMetadataInfo; - -/** - * Contract for metadata drivers. - * - * @since 2.0 - * @author Jonathan H. Wage - * @todo Rename: MetadataDriver or MappingDriver - */ -interface Driver -{ - /** - * Loads the metadata for the specified class into the provided container. - * - * @param string $className - * @param ClassMetadataInfo $metadata - */ - function loadMetadataForClass($className, ClassMetadataInfo $metadata); - - /** - * Gets the names of all mapped classes known to this driver. - * - * @return array The names of all mapped classes known to this driver. - */ - function getAllClassNames(); - - /** - * Whether the class with the specified name should have its metadata loaded. - * This is only the case if it is either mapped as an Entity or a - * MappedSuperclass. - * - * @param string $className - * @return boolean - */ - function isTransient($className); -} \ No newline at end of file diff --git a/lib/Doctrine/ORM/Mapping/Driver/DriverChain.php b/lib/Doctrine/ORM/Mapping/Driver/DriverChain.php index 77c258a18..f945426b7 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/DriverChain.php +++ b/lib/Doctrine/ORM/Mapping/Driver/DriverChain.php @@ -19,9 +19,9 @@ namespace Doctrine\ORM\Mapping\Driver; -use Doctrine\ORM\Mapping\Driver\Driver, - Doctrine\ORM\Mapping\ClassMetadataInfo, - Doctrine\ORM\Mapping\MappingException; +use Doctrine\ORM\Mapping\ClassMetadataInfo, + Doctrine\ORM\Mapping\MappingException, + Doctrine\Common\Persistence\Mapping\Driver; /** * The DriverChain allows you to add multiple other mapping drivers for @@ -68,7 +68,7 @@ class DriverChain implements Driver * @param string $className * @param ClassMetadataInfo $metadata */ - public function loadMetadataForClass($className, ClassMetadataInfo $metadata) + public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata) { foreach ($this->_drivers as $namespace => $driver) { if (strpos($className, $namespace) === 0) { diff --git a/lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php b/lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php index ff86597f6..c521124d2 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php @@ -25,7 +25,8 @@ use Doctrine\Common\Cache\ArrayCache, Doctrine\ORM\Mapping\ClassMetadataInfo, Doctrine\ORM\Mapping\MappingException, Doctrine\Common\Util\Inflector, - Doctrine\ORM\Mapping\Driver\AbstractFileDriver; + Doctrine\ORM\Mapping\Driver\AbstractFileDriver, + Doctrine\Common\Persistence\Mapping\Driver; /** * The PHPDriver includes php files which just populate ClassMetadataInfo @@ -52,7 +53,7 @@ class PHPDriver extends AbstractFileDriver /** * {@inheritdoc} */ - public function loadMetadataForClass($className, ClassMetadataInfo $metadata) + public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata) { $this->_metadata = $metadata; $this->_loadMappingFile($this->_findMappingFile($className)); diff --git a/lib/Doctrine/ORM/Mapping/Driver/StaticPHPDriver.php b/lib/Doctrine/ORM/Mapping/Driver/StaticPHPDriver.php index d89b1ed68..3dbd72154 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/StaticPHPDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/StaticPHPDriver.php @@ -22,7 +22,8 @@ namespace Doctrine\ORM\Mapping\Driver; use Doctrine\ORM\Mapping\ClassMetadataInfo, - Doctrine\ORM\Mapping\MappingException; + Doctrine\ORM\Mapping\MappingException, + Doctrine\Common\Persistence\Mapping\Driver; /** * The StaticPHPDriver calls a static loadMetadata() method on your entity @@ -54,7 +55,7 @@ class StaticPHPDriver implements Driver /** * {@inheritdoc} */ - public function loadMetadataForClass($className, ClassMetadataInfo $metadata) + public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata) { call_user_func_array(array($className, 'loadMetadata'), array($metadata)); } diff --git a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php index 3ec712b70..6bfd8d97a 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php @@ -23,7 +23,8 @@ namespace Doctrine\ORM\Mapping\Driver; use SimpleXMLElement, Doctrine\ORM\Mapping\ClassMetadataInfo, - Doctrine\ORM\Mapping\MappingException; + Doctrine\ORM\Mapping\MappingException, + Doctrine\Common\Persistence\Mapping\Driver; /** * XmlDriver is a metadata driver that enables mapping through XML files. @@ -47,7 +48,7 @@ class XmlDriver extends AbstractFileDriver /** * {@inheritdoc} */ - public function loadMetadataForClass($className, ClassMetadataInfo $metadata) + public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata) { $xmlRoot = $this->getElement($className); diff --git a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php index 0f88474f1..f0ac5cf3a 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php @@ -20,7 +20,8 @@ namespace Doctrine\ORM\Mapping\Driver; use Doctrine\ORM\Mapping\ClassMetadataInfo, - Doctrine\ORM\Mapping\MappingException; + Doctrine\ORM\Mapping\MappingException, + Doctrine\Common\Persistence\Mapping\Driver; /** * The YamlDriver reads the mapping metadata from yaml schema files. @@ -41,7 +42,7 @@ class YamlDriver extends AbstractFileDriver /** * {@inheritdoc} */ - public function loadMetadataForClass($className, ClassMetadataInfo $metadata) + public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata) { $element = $this->getElement($className); diff --git a/lib/vendor/doctrine-common b/lib/vendor/doctrine-common index 6ab5455ce..dedebc37e 160000 --- a/lib/vendor/doctrine-common +++ b/lib/vendor/doctrine-common @@ -1 +1 @@ -Subproject commit 6ab5455ce5b7cf97077b3a9a5e5e9bae4e6c84cb +Subproject commit dedebc37ef3bf28fb37c1aa5454de1efd44774dd diff --git a/tests/Doctrine/Tests/Mocks/MetadataDriverMock.php b/tests/Doctrine/Tests/Mocks/MetadataDriverMock.php index fb533f465..9674c44cb 100644 --- a/tests/Doctrine/Tests/Mocks/MetadataDriverMock.php +++ b/tests/Doctrine/Tests/Mocks/MetadataDriverMock.php @@ -2,9 +2,9 @@ namespace Doctrine\Tests\Mocks; -class MetadataDriverMock implements \Doctrine\ORM\Mapping\Driver\Driver +class MetadataDriverMock implements \Doctrine\Common\Persistence\Mapping\Driver { - public function loadMetadataForClass($className, \Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) + public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata) { return; } diff --git a/tests/Doctrine/Tests/ORM/Mapping/DriverChainTest.php b/tests/Doctrine/Tests/ORM/Mapping/DriverChainTest.php index d218aaf8f..854369a08 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/DriverChainTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/DriverChainTest.php @@ -2,7 +2,7 @@ namespace Doctrine\Tests\ORM\Mapping; -use Doctrine\ORM\Mapping\Driver\Driver; +use Doctrine\Common\Persistence\Mapping\Driver; use Doctrine\ORM\Mapping\Driver\DriverChain; require_once __DIR__ . '/../../TestInit.php'; @@ -16,13 +16,13 @@ class DriverChainTest extends \Doctrine\Tests\OrmTestCase $chain = new DriverChain(); - $driver1 = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver'); + $driver1 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver'); $driver1->expects($this->never()) ->method('loadMetadataForClass'); $driver1->expectS($this->never()) ->method('isTransient'); - $driver2 = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver'); + $driver2 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver'); $driver2->expects($this->at(0)) ->method('loadMetadataForClass') ->with($this->equalTo($className), $this->equalTo($classMetadata)); @@ -57,12 +57,12 @@ class DriverChainTest extends \Doctrine\Tests\OrmTestCase $chain = new DriverChain(); - $driver1 = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver'); + $driver1 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver'); $driver1->expects($this->once()) ->method('getAllClassNames') ->will($this->returnValue(array('Doctrine\Tests\Models\Company\Foo'))); - $driver2 = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver'); + $driver2 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver'); $driver2->expects($this->once()) ->method('getAllClassNames') ->will($this->returnValue(array('Doctrine\Tests\ORM\Mapping\Bar', 'Doctrine\Tests\ORM\Mapping\Baz', 'FooBarBaz')));