本文整理汇总了PHP中CSSMin::getAllLocalFileReferences方法的典型用法代码示例。如果您正苦于以下问题:PHP CSSMin::getAllLocalFileReferences方法的具体用法?PHP CSSMin::getAllLocalFileReferences怎么用?PHP CSSMin::getAllLocalFileReferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSSMin
的用法示例。
在下文中一共展示了CSSMin::getAllLocalFileReferences方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readStyleFile
/**
* Reads a style file.
*
* This method can be used as a callback for array_map()
*
* @param string $path File path of style file to read
* @param bool $flip
* @param ResourceLoaderContext $context (optional)
*
* @return string CSS data in script file
* @throws MWException If the file doesn't exist
*/
protected function readStyleFile($path, $flip, $context = null)
{
$localPath = $this->getLocalPath($path);
$remotePath = $this->getRemotePath($path);
if (!file_exists($localPath)) {
$msg = __METHOD__ . ": style file not found: \"{$localPath}\"";
wfDebugLog('resourceloader', $msg);
throw new MWException($msg);
}
if ($this->getStyleSheetLang($localPath) === 'less') {
$compiler = $this->getLessCompiler($context);
$style = $this->compileLessFile($localPath, $compiler);
$this->hasGeneratedStyles = true;
} else {
$style = file_get_contents($localPath);
}
if ($flip) {
$style = CSSJanus::transform($style, true, false);
}
$localDir = dirname($localPath);
$remoteDir = dirname($remotePath);
// Get and register local file references
$localFileRefs = CSSMin::getAllLocalFileReferences($style, $localDir);
foreach ($localFileRefs as $file) {
if (file_exists($file)) {
$this->localFileRefs[] = $file;
} else {
$this->missingLocalFileRefs[] = $file;
}
}
return CSSMin::remap($style, $localDir, $remoteDir, true);
}
示例2: testCommentedLocalFileReferences
/**
* CSSMin::getAllLocalFileReferences should ignore url(...) expressions
* that have been commented out.
*/
public function testCommentedLocalFileReferences()
{
$basepath = __DIR__ . '/../data/css/';
$css = file_get_contents($basepath . 'comments.css');
$files = CSSMin::getAllLocalFileReferences($css, $basepath);
$expected = array($basepath . 'not-commented.gif');
$this->assertArrayEquals($expected, $files, 'Url(...) expression in comment should be omitted.');
}