. */ namespace Doctrine\ORM\Mapping\Driver; use Doctrine\Common\DoctrineException, Doctrine\Common\Cache\ArrayCache, Doctrine\Common\Annotations\AnnotationReader, Doctrine\DBAL\Schema\AbstractSchemaManager, Doctrine\ORM\Mapping\ClassMetadataInfo, Doctrine\ORM\Mapping\MappingException, Doctrine\Common\Util\Inflector; /** * 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 Guilherme Blanco * @author Jonathan Wage * @author Roman Borschel */ class PhpDriver implements Driver { /** The directory path to look in for php files */ private $_directory; /** The array of class names found and the path to the file */ private $_classPaths = array(); public function __construct($directory) { $this->_directory = $directory; } public function loadMetadataForClass($className, ClassMetadataInfo $metadata) { $path = $this->_classPaths[$className]; include $path; } public function isTransient($className) { return true; } /** * {@inheritDoc} */ public function getAllClassNames() { if ( ! is_dir($this->_directory)) { throw MappingException::phpDriverRequiresConfiguredDirectoryPath(); } $iter = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->_directory), \RecursiveIteratorIterator::LEAVES_ONLY); $classes = array(); foreach ($iter as $item) { $info = pathinfo($item->getPathName()); if ( ! isset($info['extension']) || $info['extension'] != 'php') { continue; } $className = $info['filename']; $classes[] = $className; $this->_classPaths[$className] = $item->getPathName(); } return $classes; } }