1
0
mirror of synced 2024-12-13 22:56:04 +03:00

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.

This commit is contained in:
Jonathan H. Wage 2011-02-16 10:06:39 -06:00
parent a4a184b27c
commit c988a99d55
15 changed files with 35 additions and 89 deletions

View File

@ -20,7 +20,7 @@
namespace Doctrine\ORM; namespace Doctrine\ORM;
use Doctrine\Common\Cache\Cache, use Doctrine\Common\Cache\Cache,
Doctrine\ORM\Mapping\Driver\Driver; Doctrine\Common\Persistence\Mapping\Driver;
/** /**
* Configuration container for all configuration options of Doctrine. * Configuration container for all configuration options of Doctrine.

View File

@ -23,8 +23,7 @@ use ReflectionException,
Doctrine\ORM\ORMException, Doctrine\ORM\ORMException,
Doctrine\ORM\EntityManager, Doctrine\ORM\EntityManager,
Doctrine\DBAL\Platforms, 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 * The ClassMetadataFactory is used to create ClassMetadata objects that contain all the
@ -37,7 +36,7 @@ use ReflectionException,
* @author Jonathan Wage <jonwage@gmail.com> * @author Jonathan Wage <jonwage@gmail.com>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class ClassMetadataFactory implements ClassMetadataFactoryInterface class ClassMetadataFactory implements \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory
{ {
/** /**
* @var EntityManager * @var EntityManager

View File

@ -19,7 +19,6 @@
namespace Doctrine\ORM\Mapping; namespace Doctrine\ORM\Mapping;
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
use ReflectionClass; use ReflectionClass;
/** /**
@ -40,7 +39,7 @@ use ReflectionClass;
* @author Jonathan H. Wage <jonwage@gmail.com> * @author Jonathan H. Wage <jonwage@gmail.com>
* @since 2.0 * @since 2.0
*/ */
class ClassMetadataInfo implements ClassMetadata class ClassMetadataInfo implements \Doctrine\Common\Persistence\Mapping\ClassMetadata
{ {
/* The inheritance mapping types */ /* The inheritance mapping types */
/** /**

View File

@ -22,6 +22,7 @@
namespace Doctrine\ORM\Mapping\Driver; namespace Doctrine\ORM\Mapping\Driver;
use Doctrine\ORM\Mapping\MappingException; use Doctrine\ORM\Mapping\MappingException;
use Doctrine\Common\Persistence\Mapping\Driver;
/** /**
* Base driver for file-based metadata drivers. * Base driver for file-based metadata drivers.

View File

@ -22,7 +22,8 @@ namespace Doctrine\ORM\Mapping\Driver;
use Doctrine\Common\Cache\ArrayCache, use Doctrine\Common\Cache\ArrayCache,
Doctrine\Common\Annotations\AnnotationReader, Doctrine\Common\Annotations\AnnotationReader,
Doctrine\ORM\Mapping\ClassMetadataInfo, Doctrine\ORM\Mapping\ClassMetadataInfo,
Doctrine\ORM\Mapping\MappingException; Doctrine\ORM\Mapping\MappingException,
Doctrine\Common\Persistence\Mapping\Driver;
require __DIR__ . '/DoctrineAnnotations.php'; require __DIR__ . '/DoctrineAnnotations.php';
@ -122,7 +123,7 @@ class AnnotationDriver implements Driver
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function loadMetadataForClass($className, ClassMetadataInfo $metadata) public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata)
{ {
$class = $metadata->getReflectionClass(); $class = $metadata->getReflectionClass();

View File

@ -25,7 +25,8 @@ use Doctrine\Common\Cache\ArrayCache,
Doctrine\DBAL\Schema\SchemaException, Doctrine\DBAL\Schema\SchemaException,
Doctrine\ORM\Mapping\ClassMetadataInfo, Doctrine\ORM\Mapping\ClassMetadataInfo,
Doctrine\ORM\Mapping\MappingException, 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. * The DatabaseDriver reverse engineers the mapping metadata from a database.
@ -114,7 +115,7 @@ class DatabaseDriver implements Driver
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function loadMetadataForClass($className, ClassMetadataInfo $metadata) public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata)
{ {
$this->reverseEngineerMappingFromDatabase(); $this->reverseEngineerMappingFromDatabase();

View File

@ -1,59 +0,0 @@
<?php
/*
* $Id$
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\ORM\Mapping\Driver;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
/**
* Contract for metadata drivers.
*
* @since 2.0
* @author Jonathan H. Wage <jonwage@gmail.com>
* @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);
}

View File

@ -19,9 +19,9 @@
namespace Doctrine\ORM\Mapping\Driver; namespace Doctrine\ORM\Mapping\Driver;
use Doctrine\ORM\Mapping\Driver\Driver, use Doctrine\ORM\Mapping\ClassMetadataInfo,
Doctrine\ORM\Mapping\ClassMetadataInfo, Doctrine\ORM\Mapping\MappingException,
Doctrine\ORM\Mapping\MappingException; Doctrine\Common\Persistence\Mapping\Driver;
/** /**
* The DriverChain allows you to add multiple other mapping drivers for * The DriverChain allows you to add multiple other mapping drivers for
@ -68,7 +68,7 @@ class DriverChain implements Driver
* @param string $className * @param string $className
* @param ClassMetadataInfo $metadata * @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) { foreach ($this->_drivers as $namespace => $driver) {
if (strpos($className, $namespace) === 0) { if (strpos($className, $namespace) === 0) {

View File

@ -25,7 +25,8 @@ use Doctrine\Common\Cache\ArrayCache,
Doctrine\ORM\Mapping\ClassMetadataInfo, Doctrine\ORM\Mapping\ClassMetadataInfo,
Doctrine\ORM\Mapping\MappingException, Doctrine\ORM\Mapping\MappingException,
Doctrine\Common\Util\Inflector, 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 * The PHPDriver includes php files which just populate ClassMetadataInfo
@ -52,7 +53,7 @@ class PHPDriver extends AbstractFileDriver
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function loadMetadataForClass($className, ClassMetadataInfo $metadata) public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata)
{ {
$this->_metadata = $metadata; $this->_metadata = $metadata;
$this->_loadMappingFile($this->_findMappingFile($className)); $this->_loadMappingFile($this->_findMappingFile($className));

View File

@ -22,7 +22,8 @@
namespace Doctrine\ORM\Mapping\Driver; namespace Doctrine\ORM\Mapping\Driver;
use Doctrine\ORM\Mapping\ClassMetadataInfo, 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 * The StaticPHPDriver calls a static loadMetadata() method on your entity
@ -54,7 +55,7 @@ class StaticPHPDriver implements Driver
/** /**
* {@inheritdoc} * {@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)); call_user_func_array(array($className, 'loadMetadata'), array($metadata));
} }

View File

@ -23,7 +23,8 @@ namespace Doctrine\ORM\Mapping\Driver;
use SimpleXMLElement, use SimpleXMLElement,
Doctrine\ORM\Mapping\ClassMetadataInfo, 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. * XmlDriver is a metadata driver that enables mapping through XML files.
@ -47,7 +48,7 @@ class XmlDriver extends AbstractFileDriver
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function loadMetadataForClass($className, ClassMetadataInfo $metadata) public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata)
{ {
$xmlRoot = $this->getElement($className); $xmlRoot = $this->getElement($className);

View File

@ -20,7 +20,8 @@
namespace Doctrine\ORM\Mapping\Driver; namespace Doctrine\ORM\Mapping\Driver;
use Doctrine\ORM\Mapping\ClassMetadataInfo, 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. * The YamlDriver reads the mapping metadata from yaml schema files.
@ -41,7 +42,7 @@ class YamlDriver extends AbstractFileDriver
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function loadMetadataForClass($className, ClassMetadataInfo $metadata) public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata)
{ {
$element = $this->getElement($className); $element = $this->getElement($className);

@ -1 +1 @@
Subproject commit 6ab5455ce5b7cf97077b3a9a5e5e9bae4e6c84cb Subproject commit dedebc37ef3bf28fb37c1aa5454de1efd44774dd

View File

@ -2,9 +2,9 @@
namespace Doctrine\Tests\Mocks; 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; return;
} }

View File

@ -2,7 +2,7 @@
namespace Doctrine\Tests\ORM\Mapping; namespace Doctrine\Tests\ORM\Mapping;
use Doctrine\ORM\Mapping\Driver\Driver; use Doctrine\Common\Persistence\Mapping\Driver;
use Doctrine\ORM\Mapping\Driver\DriverChain; use Doctrine\ORM\Mapping\Driver\DriverChain;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
@ -16,13 +16,13 @@ class DriverChainTest extends \Doctrine\Tests\OrmTestCase
$chain = new DriverChain(); $chain = new DriverChain();
$driver1 = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver'); $driver1 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver');
$driver1->expects($this->never()) $driver1->expects($this->never())
->method('loadMetadataForClass'); ->method('loadMetadataForClass');
$driver1->expectS($this->never()) $driver1->expectS($this->never())
->method('isTransient'); ->method('isTransient');
$driver2 = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver'); $driver2 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver');
$driver2->expects($this->at(0)) $driver2->expects($this->at(0))
->method('loadMetadataForClass') ->method('loadMetadataForClass')
->with($this->equalTo($className), $this->equalTo($classMetadata)); ->with($this->equalTo($className), $this->equalTo($classMetadata));
@ -57,12 +57,12 @@ class DriverChainTest extends \Doctrine\Tests\OrmTestCase
$chain = new DriverChain(); $chain = new DriverChain();
$driver1 = $this->getMock('Doctrine\ORM\Mapping\Driver\Driver'); $driver1 = $this->getMock('Doctrine\Common\Persistence\Mapping\Driver');
$driver1->expects($this->once()) $driver1->expects($this->once())
->method('getAllClassNames') ->method('getAllClassNames')
->will($this->returnValue(array('Doctrine\Tests\Models\Company\Foo'))); ->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()) $driver2->expects($this->once())
->method('getAllClassNames') ->method('getAllClassNames')
->will($this->returnValue(array('Doctrine\Tests\ORM\Mapping\Bar', 'Doctrine\Tests\ORM\Mapping\Baz', 'FooBarBaz'))); ->will($this->returnValue(array('Doctrine\Tests\ORM\Mapping\Bar', 'Doctrine\Tests\ORM\Mapping\Baz', 'FooBarBaz')));