| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Detect whether request should be debugged |
| 5 |
* |
| 6 |
* @package Minify |
| 7 |
* @author Stephen Clay <steve@mrclay.org> |
| 8 |
*/ |
| 9 |
class Minify_DebugDetector |
| 10 |
{ |
| 11 |
public static function shouldDebugRequest(Minify_Env $env) |
| 12 |
{ |
| 13 |
if ($env->get('debug') !== null) { |
| 14 |
return true; |
| 15 |
} |
| 16 |
|
| 17 |
$cookieValue = $env->cookie('minifyDebug'); |
| 18 |
if ($cookieValue) { |
| 19 |
foreach (preg_split('/\\s+/', $cookieValue) as $debugUri) { |
| 20 |
$pattern = '@' . preg_quote($debugUri, '@') . '@i'; |
| 21 |
$pattern = str_replace(array('\\*', '\\?'), array('.*', '.'), $pattern); |
| 22 |
if (preg_match($pattern, $env->getRequestUri())) { |
| 23 |
return true; |
| 24 |
} |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
return false; |
| 29 |
} |
| 30 |
} |
| 31 |
|