/** * (non-PHPdoc) * @see Gedmo\Mapping.Driver::readExtendedMetadata() */ public function readExtendedMetadata(ClassMetadataInfo $meta, array &$config) { foreach ($this->_drivers as $namespace => $driver) { if (strpos($meta->name, $namespace) === 0) { $driver->readExtendedMetadata($meta, $config); return; } } throw \Gedmo\Mapping\DriverException::invalidEntity($meta->name); }
/** * Finds the mapping file for the class with the given name by searching * through the configured paths. * * @param $className * @return string The (absolute) file name. * @throws RuntimeException if not found */ protected function _findMappingFile($className) { $fileName = str_replace('\\', '.', $className) . $this->_extension; // Check whether file exists foreach ((array) $this->_paths as $path) { if (file_exists($path . DIRECTORY_SEPARATOR . $fileName)) { return $path . DIRECTORY_SEPARATOR . $fileName; } } throw \Gedmo\Mapping\DriverException::mappingFileNotFound($fileName, $className); }
/** * Get the extended driver instance which will * read the metadata required by extension * * @param ORMDriver $ormDriver * @throws DriverException if driver was not found in extension * @return Gedmo\Mapping\Driver */ private function _getDriver(ORMDriver $ormDriver) { $driver = null; if ($ormDriver instanceof \Doctrine\ORM\Mapping\Driver\DriverChain) { $driver = new Driver\Chain(); foreach ($ormDriver->getDrivers() as $namespace => $nestedOrmDriver) { $driver->addDriver($this->_getDriver($nestedOrmDriver), $namespace); } } else { $className = get_class($ormDriver); $driverName = substr($className, strrpos($className, '\\') + 1); $driverName = substr($driverName, 0, strpos($driverName, 'Driver')); // create driver instance $driverClassName = $this->_extensionNamespace . '\\Mapping\\Driver\\' . $driverName; if (!class_exists($driverClassName)) { throw DriverException::extensionDriverNotSupported($driverClassName, $driverName); } $driver = new $driverClassName(); if ($driver instanceof \Gedmo\Mapping\Driver\File) { $driver->setPaths($ormDriver->getPaths()); } } return $driver; }