本文整理汇总了PHP中Minify_Controller_Base::loadMinifier方法的典型用法代码示例。如果您正苦于以下问题:PHP Minify_Controller_Base::loadMinifier方法的具体用法?PHP Minify_Controller_Base::loadMinifier怎么用?PHP Minify_Controller_Base::loadMinifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Minify_Controller_Base
的用法示例。
在下文中一共展示了Minify_Controller_Base::loadMinifier方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadMinifier
/**
* @see Minify_Controller_Base::loadMinifier()
*/
public function loadMinifier($minifierCallback)
{
if ($this->_loadCssJsMinifiers) {
// Minify will not call for these so we must manually load
// them when Minify/HTML.php is called for.
}
parent::loadMinifier($minifierCallback);
// load Minify/HTML.php
}
示例2: loadMinifier
/**
* @see Minify_Controller_Base::loadMinifier()
*/
public function loadMinifier($minifierCallback)
{
if ($this->_loadCssJsMinifiers) {
// Minify will not call for these so we must manually load
// them when Minify/HTML.php is called for.
require_once W3TC_LIB_MINIFY_DIR . '/Minify/CSS.php';
require_once W3TC_LIB_MINIFY_DIR . '/JSMin.php';
}
parent::loadMinifier($minifierCallback);
// load Minify/HTML.php
}
示例3: _combineMinify
/**
* Combines sources and minifies the result.
*
* @return string
*/
protected static function _combineMinify()
{
$type = self::$_options['contentType'];
// ease readability
// when combining scripts, make sure all statements separated and
// trailing single line comment is terminated
$implodeSeparator = $type === self::TYPE_JS ? "\n;" : '';
// allow the user to pass a particular array of options to each
// minifier (designated by type). source objects may still override
// these
$defaultOptions = isset(self::$_options['minifierOptions'][$type]) ? self::$_options['minifierOptions'][$type] : array();
// if minifier not set, default is no minification. source objects
// may still override this
$defaultMinifier = isset(self::$_options['minifiers'][$type]) ? self::$_options['minifiers'][$type] : false;
// process groups of sources with identical minifiers/options
$content = array();
$i = 0;
$l = count(self::$_controller->sources);
$groupToProcessTogether = array();
$lastMinifier = null;
$lastOptions = null;
do {
// get next source
$source = null;
if ($i < $l) {
$source = self::$_controller->sources[$i];
/* @var Minify_Source $source */
$sourceContent = $source->getContent();
// allow the source to override our minifier and options
$minifier = null !== $source->minifier ? $source->minifier : $defaultMinifier;
$options = null !== $source->minifyOptions ? array_merge($defaultOptions, $source->minifyOptions) : $defaultOptions;
}
// do we need to process our group right now?
if ($i > 0 && (!$source || $type === self::TYPE_CSS || $minifier !== $lastMinifier || $options !== $lastOptions)) {
// minify previous sources with last settings
$imploded = implode($implodeSeparator, $groupToProcessTogether);
$groupToProcessTogether = array();
if ($lastMinifier) {
self::$_controller->loadMinifier($lastMinifier);
try {
$content[] = call_user_func($lastMinifier, $imploded, $lastOptions);
} catch (Exception $e) {
throw new Exception("Exception in minifier: " . $e->getMessage());
}
} else {
$content[] = $imploded;
}
}
// add content to the group
if ($source) {
$groupToProcessTogether[] = $sourceContent;
$lastMinifier = $minifier;
$lastOptions = $options;
}
$i++;
} while ($source);
$content = implode($implodeSeparator, $content);
if ($type === self::TYPE_CSS && false !== strpos($content, '@import')) {
$content = self::_handleCssImports($content);
}
// do any post-processing (esp. for editing build URIs)
if (self::$_options['postprocessorRequire']) {
require_once self::$_options['postprocessorRequire'];
}
if (self::$_options['postprocessor']) {
$content = call_user_func(self::$_options['postprocessor'], $content, $type);
}
return $content;
}