protected static function getNewProviderInstance($mountpointPath) { $urlParts = EyeosAbstractVirtualFile::parse_url($mountpointPath); $userMountpointConfigPath = self::getUserMountpointsPath($urlParts['principalname']); $conf = FSI::getConfiguration(EyeosAbstractVirtualFile::URL_SCHEME_USERFILES . '.scheme' . SERVICE_FILESYSTEM_CONFIGURATION_FILE_EXTENSION); $providerClassName = (string) $conf->mountpointsManager[0]->provider['class']; $params = array('filePath' => $userMountpointConfigPath); return MountpointsManager::getNewMountpointDescriptorsProviderInstance($providerClassName, $params); }
/** * Returns an IVirtualFile object corresponding to the given virtual $path. * * @param string $path The path/URL of the file. * @param array $params Optionnal addionnal parameters passed to the file class constructor. * @return IVirtualFile The file object if the FOF was able to create it or null otherwise. * @throws EyeException If an error occured during the creation of the file object. */ public function getFile($path, $params = null) { $urlParts = AdvancedPathLib::parse_url($path, AdvancedPathLib::OS_UNIX); try { $xmlConf = FSI::getConfiguration($urlParts['scheme'] . '.scheme'); } catch (EyeFileNotFoundException $e) { throw new EyeMissingConfigurationException('Missing handler configuration file for scheme ' . $urlParts['scheme'] . '://.', 0, $e); } $handlerClassName = (string) $xmlConf->handlerClassName[0]; if (!class_exists($handlerClassName)) { throw new EyeClassNotFoundException('Unable to find ' . $handlerClassName); } //autocomplete path if possible (home://myFolder => home://~currentuser/myFolder) $path = call_user_func_array(array($handlerClassName, 'autocompletePath'), array($path)); //check for mounted file first $realFile = null; if ($xmlConf->mountpointsManager->getName() != '') { $realFile = MountedFileLocator::getRealFile($path, null, $params); if ($realFile !== null) { $params['realFile'] = $realFile; } } //if no mounted path has been found, get the real file object from its locator if ($realFile === null) { $locatorClassFilename = (string) $xmlConf->locatorClassName[0]; if ($locatorClassFilename == '') { throw new EyeMissingConfigurationException('No VirtualFileLocator class has been specified in the configuration file.'); } if (!is_file(SERVICE_FILESYSTEM_VIRTUALFILEFACTORY_LOCATORS_PATH . '/' . $locatorClassFilename . '.php')) { throw new EyeFileNotFoundException('Unable to find specified VirtualFileLocator class file: ' . $locatorClassFilename . '.php.'); } require_once SERVICE_FILESYSTEM_VIRTUALFILEFACTORY_LOCATORS_PATH . '/' . $locatorClassFilename . '.php'; if (!class_exists($locatorClassFilename)) { throw new EyeClassNotFoundException('Unable to find class ' . $locatorClassFilename); } $params['realFile'] = call_user_func_array(array($locatorClassFilename, 'getRealFile'), array($path, $xmlConf->parameters, $params)); } return new $handlerClassName(AdvancedPathLib::buildUrl($urlParts), $params); }
protected static function getMountpointManagerInstance($path) { $moutpointScheme = AdvancedPathLib::parse_url($path); $moutpointScheme = $moutpointScheme['scheme']; if (!isset(self::$LoadedManagers[$moutpointScheme])) { if (!in_array($moutpointScheme, EyeosAbstractVirtualFile::$VirtualFileSchemes)) { throw new EyeInvalidArgumentException($path . ' does not represent an EyeosAbstractVirtualFile.'); } $configFile = $moutpointScheme . '.scheme' . SERVICE_FILESYSTEM_CONFIGURATION_FILE_EXTENSION; $conf = FSI::getConfiguration($configFile); $managerClassName = (string) $conf->mountpointsManager['class']; if (!$managerClassName) { throw new EyeMissingConfigurationException('No manager class found in configuration file ' . $configFile); } if (!is_file(SERVICE_FILESYSTEM_MOUNTPOINTSMANAGERS_MANAGERS_PATH . '/' . $managerClassName . '.php')) { throw new EyeFileNotFoundException(SERVICE_FILESYSTEM_MOUNTPOINTSMANAGERS_MANAGERS_PATH . '/' . $managerClassName . '.php'); } require SERVICE_FILESYSTEM_MOUNTPOINTSMANAGERS_MANAGERS_PATH . '/' . $managerClassName . '.php'; $instance = call_user_func(array($managerClassName, 'getInstance')); if (!$instance instanceof IMountpointsManager) { throw new EyeUnexpectedValueException($managerClassName . ' does not implement IMountpointsManager.'); } self::$LoadedManagers[$moutpointScheme] = $instance; } return self::$LoadedManagers[$moutpointScheme]; }