public function testUrlToPath() { $path = DIRECTORY_SEPARATOR . 'style' . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'tao-user-styles.css'; $urls = array('/style/custom/tao-user-styles.css', 'http://ex.com/style/custom/tao-user-styles.css', 'https://ex.com/style/custom/tao-user-styles.css', 'file://c/style/custom/tao-user-styles.css', 'file://D:/style/custom/tao-user-styles.css'); foreach ($urls as $url) { $this->assertEquals(helpers_File::urlToPath($url), $path); } }
/** * Import dependencies files * * @param QtiResource $qtiItemResource * @param $dependencies * @return $this * @throws AssetManagerException */ public function importDependencyFiles(QtiResource $qtiItemResource, $dependencies) { $qtiFile = $this->getSource() . \helpers_File::urlToPath($qtiItemResource->getFile()); foreach ($qtiItemResource->getDependencies() as $dependenciesFile) { if (!isset($dependencies[$dependenciesFile])) { continue; } $absolutePath = $this->getAbsolutePath($dependencies[$dependenciesFile]->getFile()); $relativePath = $this->getRelativePath($qtiFile, $absolutePath); try { $this->importAsset($absolutePath, $relativePath); } catch (\common_Exception $e) { throw new AssetManagerException('Error occurs during dependency assets handling for item: ' . $qtiItemResource->getIdentifier() . ', assetFile: ' . $relativePath, 0, $e); } } return $this; }