/** * Asset Contents * * @param string $file * @return string */ public static function assetContents($file) { $return = ''; if ($stylesheetPath = realpath(MgCacheHelper::$webRoot . $file)) { // get file info $pathinfo = pathinfo($file); // set local var for temp use in callback self::$assetDirectory = $pathinfo['dirname']; // string replacement callback $return = preg_replace_callback('/(url\\(\\s*[\'\\"]?)(.*?)([\'\\"]?\\s*\\))/', array('MgAssetHelper', 'assetContentHandler'), file_get_contents($stylesheetPath)); } // reset local temp var self::$assetDirectory = null; return $return; }