private static $jsParser;
private static $parseCacheVersion = 1;
- /** @var array Global LESS variables */
- private static $lessVars;
-
/**
* Validate a given script file; if valid returns the original source.
* If invalid, returns replacement JS source that throws an exception.
return self::$jsParser;
}
- /**
- * @return lessc
- */
- protected static function lessCompiler() {
- global $wgResourceLoaderLESSFunctions, $wgResourceLoaderLESSImportPaths;
-
- $less = new lessc();
- $less->setPreserveComments( true );
- $less->setVariables( self::getLESSVars() );
- $less->setImportDir( $wgResourceLoaderLESSImportPaths );
- foreach ( $wgResourceLoaderLESSFunctions as $name => $func ) {
- $less->registerFunction( $name, $func );
- }
- // To ensure embedded resources are refreshed when their source files
- // change, track the names and modification times of any files that
- // were embedded as data URIs in the generated CSS source.
- $less->embeddedFiles = array();
- return $less;
- }
-
- /**
- * Get global LESS variables.
- *
- * @return array: Map of variable names to string CSS values.
- */
- protected static function getLESSVars() {
- global $wgResourceLoaderLESSVars;
-
- if ( self::$lessVars === null ) {
- self::$lessVars = $wgResourceLoaderLESSVars;
- // Sort by key to ensure consistent hashing for cache lookups.
- ksort( self::$lessVars );
- }
- return self::$lessVars;
- }
-
/**
* Safe version of filemtime(), which doesn't throw a PHP warning if the file doesn't exist
* but returns 1 instead.