From e2c1d7c38a6d3b75ebdf53b2269edf13e9bd9ec2 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Tue, 10 Jul 2012 02:29:27 +0200 Subject: [PATCH] Removing deprecated StaticPHPDriver and PHPDriver modifying tests so that the new implementation in Doctrine\Common is referenced --- lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php | 78 --------- .../ORM/Mapping/Driver/StaticPHPDriver.php | 148 ------------------ lib/vendor/doctrine-dbal | 2 +- .../ORM/Mapping/PHPMappingDriverTest.php | 4 +- .../Mapping/StaticPHPMappingDriverTest.php | 2 +- .../AbstractClassMetadataExporterTest.php | 13 +- 6 files changed, 10 insertions(+), 237 deletions(-) delete mode 100644 lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php delete mode 100644 lib/Doctrine/ORM/Mapping/Driver/StaticPHPDriver.php diff --git a/lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php b/lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php deleted file mode 100644 index 4266999a4..000000000 --- a/lib/Doctrine/ORM/Mapping/Driver/PHPDriver.php +++ /dev/null @@ -1,78 +0,0 @@ -. - */ - -namespace Doctrine\ORM\Mapping\Driver; - -use Doctrine\Common\Persistence\Mapping\ClassMetadata, - Doctrine\Common\Persistence\Mapping\Driver\FileDriver; - -/** - * The PHPDriver includes php files which just populate ClassMetadata - * instances with plain php code - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @version $Revision$ - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan H. Wage - * @author Roman Borschel - */ -class PHPDriver extends FileDriver -{ - const DEFAULT_FILE_EXTENSION = '.php'; - - /** - * - * @var ClassMetadata - */ - protected $_metadata; - - /** - * {@inheritDoc} - */ - public function __construct($locator, $fileExtension = self::DEFAULT_FILE_EXTENSION) - { - parent::__construct($locator, $fileExtension); - } - - /** - * {@inheritDoc} - */ - public function loadMetadataForClass($className, ClassMetadata $metadata) - { - $this->_metadata = $metadata; - $this->getElement($className); - } - - /** - * {@inheritDoc} - */ - protected function loadMappingFile($file) - { - $result = array(); - $metadata = $this->_metadata; - include $file; - // @todo cannot assume that the only loaded metadata is $metadata. Some - // decision about the preferred approach should be taken - $result[$metadata->getName()] = $metadata; - return $result; - } -} \ No newline at end of file diff --git a/lib/Doctrine/ORM/Mapping/Driver/StaticPHPDriver.php b/lib/Doctrine/ORM/Mapping/Driver/StaticPHPDriver.php deleted file mode 100644 index 78dd237dd..000000000 --- a/lib/Doctrine/ORM/Mapping/Driver/StaticPHPDriver.php +++ /dev/null @@ -1,148 +0,0 @@ -. - */ - -namespace Doctrine\ORM\Mapping\Driver; - -use Doctrine\Common\Persistence\Mapping\ClassMetadata, - Doctrine\Common\Persistence\Mapping\Driver\MappingDriver, - Doctrine\ORM\Mapping\MappingException; - -/** - * The StaticPHPDriver calls a static loadMetadata() method on your entity - * classes where you can manually populate the ClassMetadata instance. - * - * @license http://www.opensource.org/licenses/lgpl-license.php LGPL - * @link www.doctrine-project.org - * @since 2.0 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan H. Wage - * @author Roman Borschel - */ -class StaticPHPDriver implements MappingDriver -{ - /** - * Paths of entity directories. - * - * @var array - */ - private $_paths = array(); - - /** - * Map of all class names. - * - * @var array - */ - private $_classNames; - - /** - * The file extension of mapping documents. - * - * @var string - */ - private $_fileExtension = '.php'; - - /** - * Constructor - * - * @param array $paths Paths where to look for mappings - */ - public function __construct($paths) - { - $this->addPaths((array) $paths); - } - - /** - * Add paths where to look for mappings - * - * @param array $paths - */ - public function addPaths(array $paths) - { - $this->_paths = array_unique(array_merge($this->_paths, $paths)); - } - - /** - * {@inheritDoc} - */ - public function loadMetadataForClass($className, ClassMetadata $metadata) - { - call_user_func_array(array($className, 'loadMetadata'), array($metadata)); - } - - /** - * {@inheritDoc} - */ - public function getAllClassNames() - { - if ($this->_classNames !== null) { - return $this->_classNames; - } - - if (!$this->_paths) { - throw MappingException::pathRequired(); - } - - $classes = array(); - $includedFiles = array(); - - foreach ($this->_paths as $path) { - if (!is_dir($path)) { - throw MappingException::fileMappingDriversRequireConfiguredDirectoryPath($path); - } - - $iterator = new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator($path), - \RecursiveIteratorIterator::LEAVES_ONLY - ); - - foreach ($iterator as $file) { - if ($file->getBasename($this->_fileExtension) == $file->getBasename()) { - continue; - } - - $sourceFile = realpath($file->getPathName()); - require_once $sourceFile; - $includedFiles[] = $sourceFile; - } - } - - $declared = get_declared_classes(); - - foreach ($declared as $className) { - $rc = new \ReflectionClass($className); - $sourceFile = $rc->getFileName(); - if (in_array($sourceFile, $includedFiles) && !$this->isTransient($className)) { - $classes[] = $className; - } - } - - $this->_classNames = $classes; - - return $classes; - } - - /** - * {@inheritDoc} - */ - public function isTransient($className) - { - return method_exists($className, 'loadMetadata') ? false : true; - } -} diff --git a/lib/vendor/doctrine-dbal b/lib/vendor/doctrine-dbal index 79e894b44..baf30aebd 160000 --- a/lib/vendor/doctrine-dbal +++ b/lib/vendor/doctrine-dbal @@ -1 +1 @@ -Subproject commit 79e894b4493937c0a6eae2e1c8206b188ac2eb7c +Subproject commit baf30aebd60c246b7ac149098cc8c55455c512ce diff --git a/tests/Doctrine/Tests/ORM/Mapping/PHPMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/PHPMappingDriverTest.php index 0aec237bc..c9da3dc7a 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/PHPMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/PHPMappingDriverTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\ORM\Mapping; use Doctrine\ORM\Mapping\ClassMetadata, - Doctrine\ORM\Mapping\Driver\PHPDriver, + Doctrine\Common\Persistence\Mapping\Driver\PHPDriver, Doctrine\ORM\Tools\Export\ClassMetadataExporter; require_once __DIR__ . '/../../TestInit.php'; @@ -28,7 +28,7 @@ class PHPMappingDriverTest extends AbstractMappingDriverTest /** * All class are entitier for php driver - * + * * @group DDC-889 */ public function testinvalidEntityOrMappedSuperClassShouldMentionParentClasses() diff --git a/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php index ab84a48bd..77eafe127 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php +++ b/tests/Doctrine/Tests/ORM/Mapping/StaticPHPMappingDriverTest.php @@ -3,7 +3,7 @@ namespace Doctrine\Tests\ORM\Mapping; use Doctrine\ORM\Mapping\ClassMetadata, - Doctrine\ORM\Mapping\Driver\StaticPHPDriver, + Doctrine\Common\Persistence\Mapping\Driver\StaticPHPDriver, Doctrine\ORM\Tools\Export\ClassMetadataExporter; require_once __DIR__ . '/../../TestInit.php'; diff --git a/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php b/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php index 688a29859..525bdaa65 100644 --- a/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php +++ b/tests/Doctrine/Tests/ORM/Tools/Export/AbstractClassMetadataExporterTest.php @@ -68,15 +68,14 @@ abstract class AbstractClassMetadataExporterTest extends \Doctrine\Tests\OrmTest protected function _createMetadataDriver($type, $path) { $mappingDriver = array( - 'php' => 'PHPDriver', - 'annotation' => 'AnnotationDriver', - 'xml' => 'XmlDriver', - 'yaml' => 'YamlDriver', + 'php' => 'Doctrine\Common\Persistence\Mapping\Driver\PHPDriver', + 'annotation' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver', + 'xml' => 'Doctrine\ORM\Mapping\Driver\XmlDriver', + 'yaml' => 'Doctrine\ORM\Mapping\Driver\YamlDriver', ); $this->assertArrayHasKey($type, $mappingDriver, "There is no metadata driver for the type '" . $type . "'."); - $driverName = $mappingDriver[$type]; + $class = $mappingDriver[$type]; - $class = 'Doctrine\ORM\Mapping\Driver\\' . $driverName; if ($type === 'annotation') { $driver = $this->createAnnotationDriver(array($path)); } else { @@ -388,5 +387,5 @@ class Phonenumber } class Group { - + }