diff --git a/lib/Doctrine/ORM/Configuration.php b/lib/Doctrine/ORM/Configuration.php index 80b44801d..0bc206d27 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\Common\Persistence\Mapping\Driver; + Doctrine\ORM\Mapping\Driver\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 cfa35fa27..571df0eb7 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php @@ -23,7 +23,8 @@ use ReflectionException, Doctrine\ORM\ORMException, Doctrine\ORM\EntityManager, Doctrine\DBAL\Platforms, - Doctrine\ORM\Events; + Doctrine\ORM\Events, + Doctrine\Common\Persistence\Mapping\ClassMetadataFactory as ClassMetadataFactoryInterface; /** * The ClassMetadataFactory is used to create ClassMetadata objects that contain all the @@ -36,7 +37,7 @@ use ReflectionException, * @author Jonathan Wage * @author Roman Borschel */ -class ClassMetadataFactory implements \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory +class ClassMetadataFactory implements ClassMetadataFactoryInterface { /** * @var EntityManager diff --git a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php index e94114fea..b482b1c5e 100644 --- a/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php +++ b/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php @@ -19,6 +19,7 @@ namespace Doctrine\ORM\Mapping; +use Doctrine\Common\Persistence\Mapping\ClassMetadata; use ReflectionClass; /** @@ -39,7 +40,7 @@ use ReflectionClass; * @author Jonathan H. Wage * @since 2.0 */ -class ClassMetadataInfo implements \Doctrine\Common\Persistence\Mapping\ClassMetadata +class ClassMetadataInfo implements ClassMetadata { /* The inheritance mapping types */ /** diff --git a/lib/Doctrine/ORM/Mapping/Driver/AbstractFileDriver.php b/lib/Doctrine/ORM/Mapping/Driver/AbstractFileDriver.php index b23f1620f..457b7cda7 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AbstractFileDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AbstractFileDriver.php @@ -22,7 +22,6 @@ 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 568c48dea..9eb83c2b8 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php @@ -22,8 +22,7 @@ namespace Doctrine\ORM\Mapping\Driver; use Doctrine\Common\Cache\ArrayCache, Doctrine\Common\Annotations\AnnotationReader, Doctrine\ORM\Mapping\ClassMetadataInfo, - Doctrine\ORM\Mapping\MappingException, - Doctrine\Common\Persistence\Mapping\Driver; + Doctrine\ORM\Mapping\MappingException; require __DIR__ . '/DoctrineAnnotations.php'; @@ -123,7 +122,7 @@ class AnnotationDriver implements Driver /** * {@inheritdoc} */ - public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata) + public function loadMetadataForClass($className, ClassMetadataInfo $metadata) { $class = $metadata->getReflectionClass(); diff --git a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php index ae6886fc6..0dc6a05e0 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php @@ -25,8 +25,7 @@ use Doctrine\Common\Cache\ArrayCache, Doctrine\DBAL\Schema\SchemaException, Doctrine\ORM\Mapping\ClassMetadataInfo, Doctrine\ORM\Mapping\MappingException, - Doctrine\Common\Util\Inflector, - Doctrine\Common\Persistence\Mapping\Driver; + Doctrine\Common\Util\Inflector; /** * The DatabaseDriver reverse engineers the mapping metadata from a database. @@ -115,7 +114,7 @@ class DatabaseDriver implements Driver /** * {@inheritdoc} */ - public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata) + public function loadMetadataForClass($className, ClassMetadataInfo $metadata) { $this->reverseEngineerMappingFromDatabase(); diff --git a/lib/Doctrine/ORM/Mapping/Driver/Driver.php b/lib/Doctrine/ORM/Mapping/Driver/Driver.php new file mode 100644 index 000000000..b6cfe36b4 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/Driver/Driver.php @@ -0,0 +1,59 @@ +. + */ + +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 f945426b7..77c258a18 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\ClassMetadataInfo, - Doctrine\ORM\Mapping\MappingException, - Doctrine\Common\Persistence\Mapping\Driver; +use Doctrine\ORM\Mapping\Driver\Driver, + Doctrine\ORM\Mapping\ClassMetadataInfo, + Doctrine\ORM\Mapping\MappingException; /** * 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, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata) + public function loadMetadataForClass($className, ClassMetadataInfo $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 c521124d2..ff86597f6 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php @@ -25,8 +25,7 @@ use Doctrine\Common\Cache\ArrayCache, Doctrine\ORM\Mapping\ClassMetadataInfo, Doctrine\ORM\Mapping\MappingException, Doctrine\Common\Util\Inflector, - Doctrine\ORM\Mapping\Driver\AbstractFileDriver, - Doctrine\Common\Persistence\Mapping\Driver; + Doctrine\ORM\Mapping\Driver\AbstractFileDriver; /** * The PHPDriver includes php files which just populate ClassMetadataInfo @@ -53,7 +52,7 @@ class PHPDriver extends AbstractFileDriver /** * {@inheritdoc} */ - public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata) + public function loadMetadataForClass($className, ClassMetadataInfo $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 3dbd72154..d89b1ed68 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/StaticPHPDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/StaticPHPDriver.php @@ -22,8 +22,7 @@ namespace Doctrine\ORM\Mapping\Driver; use Doctrine\ORM\Mapping\ClassMetadataInfo, - Doctrine\ORM\Mapping\MappingException, - Doctrine\Common\Persistence\Mapping\Driver; + Doctrine\ORM\Mapping\MappingException; /** * The StaticPHPDriver calls a static loadMetadata() method on your entity @@ -55,7 +54,7 @@ class StaticPHPDriver implements Driver /** * {@inheritdoc} */ - public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata) + public function loadMetadataForClass($className, ClassMetadataInfo $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 6bfd8d97a..3ec712b70 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php @@ -23,8 +23,7 @@ namespace Doctrine\ORM\Mapping\Driver; use SimpleXMLElement, Doctrine\ORM\Mapping\ClassMetadataInfo, - Doctrine\ORM\Mapping\MappingException, - Doctrine\Common\Persistence\Mapping\Driver; + Doctrine\ORM\Mapping\MappingException; /** * XmlDriver is a metadata driver that enables mapping through XML files. @@ -48,7 +47,7 @@ class XmlDriver extends AbstractFileDriver /** * {@inheritdoc} */ - public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata) + public function loadMetadataForClass($className, ClassMetadataInfo $metadata) { $xmlRoot = $this->getElement($className); diff --git a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php index f0ac5cf3a..0f88474f1 100644 --- a/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php +++ b/lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php @@ -20,8 +20,7 @@ namespace Doctrine\ORM\Mapping\Driver; use Doctrine\ORM\Mapping\ClassMetadataInfo, - Doctrine\ORM\Mapping\MappingException, - Doctrine\Common\Persistence\Mapping\Driver; + Doctrine\ORM\Mapping\MappingException; /** * The YamlDriver reads the mapping metadata from yaml schema files. @@ -42,7 +41,7 @@ class YamlDriver extends AbstractFileDriver /** * {@inheritdoc} */ - public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata) + public function loadMetadataForClass($className, ClassMetadataInfo $metadata) { $element = $this->getElement($className); diff --git a/lib/vendor/doctrine-common b/lib/vendor/doctrine-common index dedebc37e..6ab5455ce 160000 --- a/lib/vendor/doctrine-common +++ b/lib/vendor/doctrine-common @@ -1 +1 @@ -Subproject commit dedebc37ef3bf28fb37c1aa5454de1efd44774dd +Subproject commit 6ab5455ce5b7cf97077b3a9a5e5e9bae4e6c84cb diff --git a/tests/Doctrine/Tests/Mocks/MetadataDriverMock.php b/tests/Doctrine/Tests/Mocks/MetadataDriverMock.php index 9674c44cb..fb533f465 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\Common\Persistence\Mapping\Driver +class MetadataDriverMock implements \Doctrine\ORM\Mapping\Driver\Driver { - public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata) + public function loadMetadataForClass($className, \Doctrine\ORM\Mapping\ClassMetadataInfo $metadata) { return; } diff --git a/tests/Doctrine/Tests/ORM/Mapping/DriverChainTest.php b/tests/Doctrine/Tests/ORM/Mapping/DriverChainTest.php index 854369a08..d218aaf8f 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\Common\Persistence\Mapping\Driver; +use Doctrine\ORM\Mapping\Driver\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\Common\Persistence\Mapping\Driver'); + $driver1 = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver'); $driver1->expects($this->never()) ->method('loadMetadataForClass'); $driver1->expectS($this->never()) ->method('isTransient'); - $driver2 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver'); + $driver2 = $this->getMock('Doctrine\ORM\Mapping\Driver\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\Common\Persistence\Mapping\Driver'); + $driver1 = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver'); $driver1->expects($this->once()) ->method('getAllClassNames') ->will($this->returnValue(array('Doctrine\Tests\Models\Company\Foo'))); - $driver2 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver'); + $driver2 = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver'); $driver2->expects($this->once()) ->method('getAllClassNames') ->will($this->returnValue(array('Doctrine\Tests\ORM\Mapping\Bar', 'Doctrine\Tests\ORM\Mapping\Baz', 'FooBarBaz')));