当前位置: 首页>>代码示例>>PHP>>正文


PHP Minify::_options方法代码示例

本文整理汇总了PHP中Minify::_options方法的典型用法代码示例。如果您正苦于以下问题:PHP Minify::_options方法的具体用法?PHP Minify::_options怎么用?PHP Minify::_options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Minify的用法示例。


在下文中一共展示了Minify::_options方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: serve

 /**
  * Serve a request for a minified file. 
  * 
  * Here are the available options and defaults in the base controller:
  * 
  * 'isPublic' : send "public" instead of "private" in Cache-Control 
  * headers, allowing shared caches to cache the output. (default true)
  * 
  * 'quiet' : set to true to have serve() return an array rather than sending
  * any headers/output (default false)
  * 
  * 'encodeOutput' : set to false to disable content encoding, and not send
  * the Vary header (default true)
  * 
  * 'encodeMethod' : generally you should let this be determined by 
  * HTTP_Encoder (leave null), but you can force a particular encoding
  * to be returned, by setting this to 'gzip' or '' (no encoding)
  * 
  * 'encodeLevel' : level of encoding compression (0 to 9, default 9)
  * 
  * 'contentTypeCharset' : appended to the Content-Type header sent. Set to a falsey
  * value to remove. (default 'utf-8')  
  * 
  * 'maxAge' : set this to the number of seconds the client should use its cache
  * before revalidating with the server. This sets Cache-Control: max-age and the
  * Expires header. Unlike the old 'setExpires' setting, this setting will NOT
  * prevent conditional GETs. Note this has nothing to do with server-side caching.
  * 
  * 'rewriteCssUris' : If true, serve() will automatically set the 'currentDir'
  * minifier option to enable URI rewriting in CSS files (default true)
  * 
  * 'bubbleCssImports' : If true, all @import declarations in combined CSS
  * files will be move to the top. Note this may alter effective CSS values
  * due to a change in order. (default false)
  * 
  * 'debug' : set to true to minify all sources with the 'Lines' controller, which
  * eases the debugging of combined files. This also prevents 304 responses.
  * @see Minify_Lines::minify()
  * 
  * 'minifiers' : to override Minify's default choice of minifier function for 
  * a particular content-type, specify your callback under the key of the 
  * content-type:
  * <code>
  * // call customCssMinifier($css) for all CSS minification
  * $options['minifiers'][Minify::TYPE_CSS] = 'customCssMinifier';
  * 
  * // don't minify Javascript at all
  * $options['minifiers'][Minify::TYPE_JS] = '';
  * </code>
  * 
  * 'minifierOptions' : to send options to the minifier function, specify your options
  * under the key of the content-type. E.g. To send the CSS minifier an option: 
  * <code>
  * // give CSS minifier array('optionName' => 'optionValue') as 2nd argument 
  * $options['minifierOptions'][Minify::TYPE_CSS]['optionName'] = 'optionValue';
  * </code>
  * 
  * 'contentType' : (optional) this is only needed if your file extension is not 
  * js/css/html. The given content-type will be sent regardless of source file
  * extension, so this should not be used in a Groups config with other
  * Javascript/CSS files.
  * 
  * Any controller options are documented in that controller's setupSources() method.
  * 
  * @param mixed $controller instance of subclass of Minify_Controller_Base or string
  * name of controller. E.g. 'Files'
  * 
  * @param array $options controller/serve options
  * 
  * @return mixed null, or, if the 'quiet' option is set to true, an array
  * with keys "success" (bool), "statusCode" (int), "content" (string), and
  * "headers" (array).
  */
 public static function serve($controller, $options = array())
 {
     if (!self::$isDocRootSet && 0 === stripos(PHP_OS, 'win')) {
         self::setDocRoot();
     }
     if (is_string($controller)) {
         // make $controller into object
         $class = 'Minify_Controller_' . $controller;
         if (!class_exists($class, false)) {
             require_once "Minify/Controller/" . str_replace('_', '/', $controller) . ".php";
         }
         $controller = new $class();
         /* @var Minify_Controller_Base $controller */
     }
     // set up controller sources and mix remaining options with
     // controller defaults
     $options = $controller->setupSources($options);
     $options = $controller->analyzeSources($options);
     self::$_options = $controller->mixInDefaultOptions($options);
     // check request validity
     if (!$controller->sources) {
         // invalid request!
         if (!self::$_options['quiet']) {
             self::_errorExit(self::$_options['badRequestHeader'], self::URL_DEBUG);
         } else {
             list(, $statusCode) = explode(' ', self::$_options['badRequestHeader']);
             return array('success' => false, 'statusCode' => (int) $statusCode, 'content' => '', 'headers' => array());
//.........这里部分代码省略.........
开发者ID:mover5,项目名称:imobackup,代码行数:101,代码来源:Minify.php

示例2: serve

 /**
  * Serve a request for a minified file.
  *
  * Here are the available options and defaults in the base controller:
  *
  * 'isPublic' : send "public" instead of "private" in Cache-Control
  * headers, allowing shared caches to cache the output. (default true)
  *
  * 'quiet' : set to true to have serve() return an array rather than sending
  * any headers/output (default false)
  *
  * 'encodeOutput' : set to false to disable content encoding, and not send
  * the Vary header (default true)
  *
  * 'encodeMethod' : generally you should let this be determined by
  * HTTP_Encoder (leave null), but you can force a particular encoding
  * to be returned, by setting this to 'gzip' or '' (no encoding)
  *
  * 'encodeLevel' : level of encoding compression (0 to 9, default 9)
  *
  * 'contentTypeCharset' : appended to the Content-Type header sent. Set to a falsey
  * value to remove. (default 'utf-8')
  *
  * 'maxAge' : set this to the number of seconds the client should use its cache
  * before revalidating with the server. This sets Cache-Control: max-age and the
  * Expires header. Unlike the old 'setExpires' setting, this setting will NOT
  * prevent conditional GETs. Note this has nothing to do with server-side caching.
  *
  * 'rewriteCssUris' : If true, serve() will automatically set the 'currentDir'
  * minifier option to enable URI rewriting in CSS files (default true)
  *
  * 'bubbleCssImports' : If true, all @import declarations in combined CSS
  * files will be move to the top. Note this may alter effective CSS values
  * due to a change in order. (default false)
  *
  * 'debug' : set to true to minify all sources with the 'Lines' controller, which
  * eases the debugging of combined files. This also prevents 304 responses.
  * @see Minify_Lines::minify()
  *
  * 'minifiers' : to override Minify's default choice of minifier function for
  * a particular content-type, specify your callback under the key of the
  * content-type:
  * <code>
  * // call customCssMinifier($css) for all CSS minification
  * $options['minifiers'][Minify::TYPE_CSS] = 'customCssMinifier';
  *
  * // don't minify Javascript at all
  * $options['minifiers'][Minify::TYPE_JS] = '';
  * </code>
  *
  * 'minifierOptions' : to send options to the minifier function, specify your options
  * under the key of the content-type. E.g. To send the CSS minifier an option:
  * <code>
  * // give CSS minifier array('optionName' => 'optionValue') as 2nd argument
  * $options['minifierOptions'][Minify::TYPE_CSS]['optionName'] = 'optionValue';
  * </code>
  *
  * 'contentType' : (optional) this is only needed if your file extension is not
  * js/css/html. The given content-type will be sent regardless of source file
  * extension, so this should not be used in a Groups config with other
  * Javascript/CSS files.
  *
  * Any controller options are documented in that controller's setupSources() method.
  *
  * @param mixed instance of subclass of Minify_Controller_Base or string name of
  * controller. E.g. 'Files'
  *
  * @param array $options controller/serve options
  *
  * @return mixed null, or, if the 'quiet' option is set to true, an array
  * with keys "success" (bool), "statusCode" (int), "content" (string), and
  * "headers" (array).
  */
 public static function serve($controller, $options = array())
 {
     if (is_string($controller)) {
         // make $controller into object
         $class = 'Minify_Controller_' . $controller;
         if (!class_exists($class, false)) {
             require_once W3TC_LIB_MINIFY_DIR . "/Minify/Controller/" . str_replace('_', '/', $controller) . ".php";
         }
         $controller = new $class();
     }
     // set up controller sources and mix remaining options with
     // controller defaults
     $options = $controller->setupSources($options);
     $options = $controller->analyzeSources($options);
     self::$_options = $controller->mixInDefaultOptions($options);
     // check request validity
     if (!$controller->sources) {
         // invalid request!
         if (!self::$_options['quiet']) {
             header(self::$_options['badRequestHeader']);
             echo self::$_options['badRequestHeader'];
             return;
         } else {
             list(, $statusCode) = explode(' ', self::$_options['badRequestHeader']);
             return array('success' => false, 'statusCode' => (int) $statusCode, 'content' => '', 'headers' => array());
         }
     }
//.........这里部分代码省略.........
开发者ID:nuevomediagroup,项目名称:nmg-code,代码行数:101,代码来源:Minify.php


注:本文中的Minify::_options方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。