diff --git a/lib/Doctrine/ORM/Mapping/Driver/PhpDriver.php b/lib/Doctrine/ORM/Mapping/Driver/PhpDriver.php new file mode 100644 index 000000000..6b6954b83 --- /dev/null +++ b/lib/Doctrine/ORM/Mapping/Driver/PhpDriver.php @@ -0,0 +1,71 @@ +. + */ + +namespace Doctrine\ORM\Mapping\Driver; + +use Doctrine\Common\Cache\ArrayCache, + Doctrine\Common\Annotations\AnnotationReader, + Doctrine\DBAL\Schema\AbstractSchemaManager, + Doctrine\ORM\Mapping\ClassMetadataInfo, + Doctrine\ORM\Mapping\MappingException, + Doctrine\Common\Util\Inflector, + Doctrine\ORM\Mapping\Driver\AbstractFileDriver; + +/** + * The PhpDriver includes php files which just populate ClassMetadataInfo + * 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 + * @todo Rename: PHPDriver + */ +class PhpDriver extends AbstractFileDriver +{ + /** + * {@inheritdoc} + */ + protected $_fileExtension = '.php'; + protected $_metadata; + + /** + * {@inheritdoc} + */ + public function loadMetadataForClass($className, ClassMetadataInfo $metadata) + { + $this->_metadata = $metadata; + $this->_loadMappingFile($this->_findMappingFile($className)); + } + + /** + * {@inheritdoc} + */ + protected function _loadMappingFile($file) + { + $metadata = $this->_metadata; + include $file; + } +} \ No newline at end of file diff --git a/lib/Doctrine/ORM/Persisters/AbstractEntityInheritancePersister.php b/lib/Doctrine/ORM/Persisters/AbstractEntityInheritancePersister.php index 512f636e2..0515e4dc0 100644 --- a/lib/Doctrine/ORM/Persisters/AbstractEntityInheritancePersister.php +++ b/lib/Doctrine/ORM/Persisters/AbstractEntityInheritancePersister.php @@ -37,7 +37,7 @@ abstract class AbstractEntityInheritancePersister extends BasicEntityPersister * * @var array */ - /*private*/protected $_declaringClassMap = array(); + private $_declaringClassMap = array(); /** * {@inheritdoc} diff --git a/tests/Doctrine/Tests/ORM/Mapping/AllTests.php b/tests/Doctrine/Tests/ORM/Mapping/AllTests.php index 06bfe498f..dcd5c768c 100644 --- a/tests/Doctrine/Tests/ORM/Mapping/AllTests.php +++ b/tests/Doctrine/Tests/ORM/Mapping/AllTests.php @@ -23,7 +23,7 @@ class AllTests $suite->addTestSuite('Doctrine\Tests\ORM\Mapping\XmlMappingDriverTest'); $suite->addTestSuite('Doctrine\Tests\ORM\Mapping\YamlMappingDriverTest'); $suite->addTestSuite('Doctrine\Tests\ORM\Mapping\AnnotationDriverTest'); - //$suite->addTestSuite('Doctrine\Tests\ORM\Mapping\PHPMappingDriverTest'); FILE MISSING!!! + $suite->addTestSuite('Doctrine\Tests\ORM\Mapping\PHPMappingDriverTest'); $suite->addTestSuite('Doctrine\Tests\ORM\Mapping\StaticPHPMappingDriverTest'); $suite->addTestSuite('Doctrine\Tests\ORM\Mapping\ClassMetadataFactoryTest'); $suite->addTestSuite('Doctrine\Tests\ORM\Mapping\ClassMetadataLoadEventTest'); diff --git a/tests/Doctrine/Tests/ORM/Mapping/PhpMappingDriverTest.php b/tests/Doctrine/Tests/ORM/Mapping/PhpMappingDriverTest.php new file mode 100644 index 000000000..50bfcb819 --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Mapping/PhpMappingDriverTest.php @@ -0,0 +1,31 @@ +addMappingSource(__DIR__ . DIRECTORY_SEPARATOR . 'yaml'); + + $exporter = $cme->getExporter('php', $path); + $exporter->setMetadatas($cme->getMetadatas()); + $exporter->export(); + */ + + return new PhpDriver($path); + } +} \ No newline at end of file