Minify_DebugDetector::shouldDebugRequest PHP Method

shouldDebugRequest() public static method

public static shouldDebugRequest ( Minify_Env $env )
$env Minify_Env
    public static function shouldDebugRequest(Minify_Env $env)
    {
        if ($env->get('debug') !== null) {
            return true;
        }
        $cookieValue = $env->cookie('minifyDebug');
        if ($cookieValue) {
            foreach (preg_split('/\\s+/', $cookieValue) as $debugUri) {
                $pattern = '@' . preg_quote($debugUri, '@') . '@i';
                $pattern = str_replace(array('\\*', '\\?'), array('.*', '.'), $pattern);
                if (preg_match($pattern, $env->getRequestUri())) {
                    return true;
                }
            }
        }
        return false;
    }

Usage Example

Example #1
0
 public function action_index()
 {
     $group = $this->request->param('group');
     if (!empty($group)) {
         $_GET['g'] = $group;
     }
     $config = Kohana::$config->load('minify');
     Minify::$uploaderHoursBehind = $config['uploaderHoursBehind'];
     Minify::setCache(isset($config['cachePath']) ? $config['cachePath'] : '', $config['cacheFileLocking']);
     if ($config['documentRoot']) {
         $_SERVER['DOCUMENT_ROOT'] = $config['documentRoot'];
         Minify::$isDocRootSet = TRUE;
     }
     $serve_options = $config['serveOptions'];
     $serve_options['minifierOptions']['text/css']['symlinks'] = $config['symlinks'];
     foreach ($config['symlinks'] as $uri => $target) {
         $serve_options['minApp']['allowDirs'][] = $target;
     }
     if ($config['allowDebugFlag']) {
         $serve_options['debug'] = Minify_DebugDetector::shouldDebugRequest($_COOKIE, $_GET, $_SERVER['REQUEST_URI']);
     }
     if ($config['errorLogger']) {
         if (TRUE === $config['errorLogger']) {
             Minify_Logger::setLogger(FirePHP::getInstance(true));
         } else {
             Minify_Logger::setLogger($config['errorLogger']);
         }
     }
     // Check for URI versioning
     if (preg_match('/&\\d/', Arr::get($_SERVER, 'QUERY_STRING'))) {
         $serve_options['maxAge'] = 31536000;
     }
     if (isset($_GET['g'])) {
         // well need groups config
         $serve_options['minApp']['groups'] = $config['groupsConfig'];
     }
     if (isset($_GET['f']) or isset($_GET['g'])) {
         $response = Minify::serve(new Minify_Controller_MinApp(), array('quiet' => TRUE) + $serve_options);
         $this->response->headers($response['headers'])->status($response['statusCode'])->body($response['content']);
     }
 }
All Usage Examples Of Minify_DebugDetector::shouldDebugRequest
Minify_DebugDetector