. */ 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; } }