本文整理匯總了PHP中Magento\Framework\View\FileSystem::getRelatedPath方法的典型用法代碼示例。如果您正苦於以下問題:PHP FileSystem::getRelatedPath方法的具體用法?PHP FileSystem::getRelatedPath怎麽用?PHP FileSystem::getRelatedPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Magento\Framework\View\FileSystem
的用法示例。
在下文中一共展示了FileSystem::getRelatedPath方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testReferencesFromStaticFiles
/**
* Scan references to files from other static files and assert they are correct
*
* The CSS or LESS files may refer to other resources using @import or url() notation
* We want to check integrity of all these references
* Note that the references may have syntax specific to the Magento preprocessing subsystem
*
* @param string $area
* @param string $themePath
* @param string $locale
* @param string $module
* @param string $filePath
* @param string $absolutePath
* @dataProvider referencesFromStaticFilesDataProvider
*/
public function testReferencesFromStaticFiles($area, $themePath, $locale, $module, $filePath, $absolutePath)
{
$contents = file_get_contents($absolutePath);
preg_match_all(\Magento\Framework\View\Url\CssResolver::REGEX_CSS_RELATIVE_URLS, $contents, $matches);
foreach ($matches[1] as $relatedResource) {
if (false !== strpos($relatedResource, '@')) {
// unable to parse paths with LESS variables/mixins
continue;
}
list($relatedModule, $relatedPath) = \Magento\Framework\View\Asset\Repository::extractModule($relatedResource);
if ($relatedModule) {
$fallbackModule = $relatedModule;
} else {
if ('less' == pathinfo($filePath, PATHINFO_EXTENSION)) {
/**
* The LESS library treats the related resources with relative links not in the same way as CSS:
* when another LESS file is included, it is embedded directly into the resulting document, but the
* relative paths of related resources are not adjusted accordingly to the new root file.
* Probably it is a bug of the LESS library.
*/
$this->markTestSkipped("Due to LESS library specifics, the '{$relatedResource}' cannot be tested.");
}
$fallbackModule = $module;
$relatedPath = \Magento\Framework\View\FileSystem::getRelatedPath($filePath, $relatedResource);
}
// the $relatedPath will be suitable for feeding to the fallback system
$this->assertNotEmpty($this->getStaticFile($area, $themePath, $locale, $relatedPath, $fallbackModule), "The related resource cannot be resolved through fallback: '{$relatedResource}'");
}
}
示例2: createRelated
/**
* Create a file asset with path relative to specified local asset
*
* @param string $fileId
* @param LocalInterface $relativeTo
* @return File
*/
public function createRelated($fileId, LocalInterface $relativeTo)
{
list($module, $filePath) = self::extractModule($fileId);
if ($module) {
return $this->createSimilar($fileId, $relativeTo);
}
$filePath = \Magento\Framework\View\FileSystem::getRelatedPath($relativeTo->getFilePath(), $filePath);
return $this->createSimilar($filePath, $relativeTo);
}