本文整理汇总了PHP中Less_Cache::Regen方法的典型用法代码示例。如果您正苦于以下问题:PHP Less_Cache::Regen方法的具体用法?PHP Less_Cache::Regen怎么用?PHP Less_Cache::Regen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Less_Cache
的用法示例。
在下文中一共展示了Less_Cache::Regen方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: CompareFile
/**
* Compare the parser results with the expected css
*
*/
function CompareFile($expected_file)
{
$less_file = $this->TranslateFile($expected_file);
$expected_css = trim(file_get_contents($expected_file));
// Check with standard parser
echo "\n " . basename($expected_file);
echo "\n - Standard Compiler";
$parser = new Less_Parser();
$parser->parseFile($less_file);
$css = $parser->getCss();
$css = trim($css);
$this->assertEquals($expected_css, $css);
// Check with cache
if ($this->cache_dir) {
$options = array('cache_dir' => $this->cache_dir);
$files = array($less_file => '');
echo "\n - Regenerating Cache";
$css_file_name = Less_Cache::Regen($files, $options);
$css = file_get_contents($this->cache_dir . '/' . $css_file_name);
$css = trim($css);
$this->assertEquals($expected_css, $css);
// Check using the cached data
echo "\n - Using Cache";
$css_file_name = Less_Cache::Get($files, $options);
$css = file_get_contents($this->cache_dir . '/' . $css_file_name);
$css = trim($css);
$this->assertEquals($expected_css, $css);
}
}
示例2: compileFile
/**
* Compile a LESS file inside a theme.
*
* @param string $theme Theme containing file
* @param string $less Relative path to LESS file
*
* @return void
*/
protected function compileFile($theme, $less)
{
$parts = explode(':', $less);
$less = $parts[0];
$finalOutDir = $this->basePath . '/themes/' . $theme . '/css/';
list($fileName, ) = explode('.', $less);
$finalFile = $finalOutDir . $fileName . '.css';
$this->logMessage("\tcompiling '" . $less . "' into '" . $finalFile . "'");
$start = microtime(true);
$directories = [];
$info = new ThemeInfo($this->basePath . '/themes', $theme);
foreach (array_keys($info->getThemeInfo()) as $curTheme) {
$directories["{$this->basePath}/themes/{$curTheme}/less/"] = $this->fakePath . "themes/{$curTheme}/css/less";
}
$lessDir = $this->basePath . '/themes/' . $theme . '/less/';
if (!file_exists($lessDir . $less)) {
$this->logMessage("\t\t" . $lessDir . $less . ' does not exist; skipping.');
return;
}
$outFile = \Less_Cache::Regen([$lessDir . $less => $this->fakePath . "themes/{$theme}/css/less"], ['cache_dir' => $this->tempPath, 'cache_method' => false, 'compress' => true, 'import_dirs' => $directories]);
$css = file_get_contents($this->tempPath . '/' . $outFile);
if (!is_dir(dirname($finalFile))) {
mkdir(dirname($finalFile));
}
file_put_contents($finalFile, $this->makeRelative($css, $less));
$this->logMessage("\t\t" . (microtime(true) - $start) . ' sec');
}