Skip to content

Commit

Permalink
Revert "Removing old Driver interface in favor of the new one in Comm…
Browse files Browse the repository at this point in the history
…on\Persistence. Also changed to use fully qualified class name for interfaces in common to avoid weird aliases."

This reverts commit c988a99.
  • Loading branch information
jwage committed Feb 16, 2011
1 parent c988a99 commit 839b6dd
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 35 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/ORM/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions lib/Doctrine/ORM/Mapping/ClassMetadataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
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
Expand All @@ -36,7 +37,7 @@
* @author Jonathan Wage <[email protected]>
* @author Roman Borschel <[email protected]>
*/
class ClassMetadataFactory implements \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory
class ClassMetadataFactory implements ClassMetadataFactoryInterface
{
/**
* @var EntityManager
Expand Down
3 changes: 2 additions & 1 deletion lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

namespace Doctrine\ORM\Mapping;

use Doctrine\Common\Persistence\Mapping\ClassMetadata;
use ReflectionClass;

/**
Expand All @@ -39,7 +40,7 @@
* @author Jonathan H. Wage <[email protected]>
* @since 2.0
*/
class ClassMetadataInfo implements \Doctrine\Common\Persistence\Mapping\ClassMetadata
class ClassMetadataInfo implements ClassMetadata
{
/* The inheritance mapping types */
/**
Expand Down
1 change: 0 additions & 1 deletion lib/Doctrine/ORM/Mapping/Driver/AbstractFileDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 2 additions & 3 deletions lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
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';

Expand Down Expand Up @@ -123,7 +122,7 @@ public function setFileExtension($fileExtension)
/**
* {@inheritdoc}
*/
public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata)
public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
{
$class = $metadata->getReflectionClass();

Expand Down
5 changes: 2 additions & 3 deletions lib/Doctrine/ORM/Mapping/Driver/DatabaseDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
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.
Expand Down Expand Up @@ -115,7 +114,7 @@ private function reverseEngineerMappingFromDatabase()
/**
* {@inheritdoc}
*/
public function loadMetadataForClass($className, \Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata)
public function loadMetadataForClass($className, ClassMetadataInfo $metadata)
{
$this->reverseEngineerMappingFromDatabase();

Expand Down
59 changes: 59 additions & 0 deletions lib/Doctrine/ORM/Mapping/Driver/Driver.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?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 <[email protected]>
* @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);
}
8 changes: 4 additions & 4 deletions lib/Doctrine/ORM/Mapping/Driver/DriverChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -68,7 +68,7 @@ public function getDrivers()
* @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) {
Expand Down
5 changes: 2 additions & 3 deletions lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
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
Expand All @@ -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));
Expand Down
5 changes: 2 additions & 3 deletions lib/Doctrine/ORM/Mapping/Driver/StaticPHPDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -55,7 +54,7 @@ public function addPaths(array $paths)
/**
* {@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));
}
Expand Down
5 changes: 2 additions & 3 deletions lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@

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.
Expand All @@ -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);

Expand Down
5 changes: 2 additions & 3 deletions lib/Doctrine/ORM/Mapping/Driver/YamlDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion lib/vendor/doctrine-common
Submodule doctrine-common updated 1 files
+0 −56 lib/Doctrine/Common/Persistence/Mapping/Driver.php
4 changes: 2 additions & 2 deletions tests/Doctrine/Tests/Mocks/MetadataDriverMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions tests/Doctrine/Tests/ORM/Mapping/DriverChainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -16,13 +16,13 @@ public function testDelegateToMatchingNamespaceDriver()

$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));
Expand Down Expand Up @@ -57,12 +57,12 @@ public function testGatherAllClassNames()

$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')));
Expand Down

0 comments on commit 839b6dd

Please sign in to comment.