Ejemplo n.º 1
0
 /**
  *	Path For Asset Url
  *	@param string assetUrl
  *	@return string
  */
 public static function pathForAssetUrl($assetUrl, $assetType = null)
 {
     if (Router::isSiteUrl($assetUrl)) {
         list($assetMapFragment, $assetUrl) = array_pad(explode("/", Router::relativeUrl($assetUrl), 2), 2, null);
         $file = File::create([BASE_PATH, static::pathForAssetMap($assetMapFragment), $assetUrl]);
         if ($file->exists()) {
             return $file->path;
         }
         // //Is it a folder?
         // $folder = Folder::create([BASE_PATH, static::pathForAssetMap($assetMapFragment), $assetUrl]);
         // if($folder->exists()){
         // 	return $folder->path;
         // }
         return null;
     }
     return $assetUrl;
 }
Ejemplo n.º 2
0
 /**
  *	Url For Path
  *	@param string $path
  *	@return string
  */
 public static function urlForPath($path)
 {
     $path = Router::relativeUrl($path);
     $assetMaps = StaticStore::shared()->get(ConfigStore::CONFIG_KEY)->get("assets")->get("asset_map");
     $assetMaps->uasort(function ($a, $b) {
         return strlen($b) - strlen($a);
     });
     foreach ($assetMaps as $assetMap => $searchPath) {
         if (strcasecmp(substr($path, 0, strlen($searchPath)), $searchPath) === 0) {
             $path = Router::buildPath($assetMap, substr($path, strlen($searchPath)));
             break;
         }
     }
     return Router::absoluteUrl($path);
 }