/** * Get an instance of a mapping driver * * @param string $type The type of mapping driver (yaml, xml, annotation, etc.) * @param string $source The source for the driver * @return AbstractDriver $driver */ public function getMappingDriver($type, $source = null) { if (!isset($this->_mappingDrivers[$type])) { return false; } $class = $this->_mappingDrivers[$type]; if (is_subclass_of($class, 'Doctrine\\ORM\\Mapping\\Driver\\AbstractFileDriver')) { if (is_null($source)) { throw DoctrineException::fileMappingDriversRequireDirectoryPath(); } $driver = new $class($source); } else { if ($class == 'Doctrine\\ORM\\Mapping\\Driver\\AnnotationDriver') { $reader = new \Doctrine\Common\Annotations\AnnotationReader(new \Doctrine\Common\Cache\ArrayCache()); $reader->setDefaultAnnotationNamespace('Doctrine\\ORM\\Mapping\\'); $driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, $source); } else { $driver = new $class($source); } } return $driver; }