示例#1
0
 /**
  * Lookup the path of an asset.
  *
  * @param string $subpath The subpath of the asset, relative an addon root.
  * @param Addon $addon The addon that should contain the asset.
  * @param bool $mustExist Whether or not the asset must exist in the addon.
  * @return string
  */
 public function lookupAsset($subpath, Addon $addon = null, $mustExist = true)
 {
     $subpath = '/' . ltrim($subpath, '\\/');
     // First lookup the asset on the theme.
     foreach ($this->themeSubdirs() as $subdir) {
         if (file_exists(PATH_ROOT . $subdir . $subpath)) {
             return $subdir . $subpath;
         }
     }
     if (isset($addon)) {
         $path = $addon->getSubdir() . $subpath;
         if ($mustExist && !file_exists(PATH_ROOT . $path)) {
             return '';
         } else {
             return $path;
         }
     } else {
         return '';
     }
 }