Back to WebAssetItem class

Method getUri

public string
getUri
(mixed $resolvePath = true)
Get the file path
Parameters
  • bool $resolvePath Whether need to search for a real paths
Returns
  • string The resolved path if resolved, else an empty string.
Since
  • 4.0.0
Class: WebAssetItem
Project: Joomla

Method getUri - Source code

/**
 * Get the file path
 *
 * @param   boolean  $resolvePath  Whether need to search for a real paths
 *
 * @return  string  The resolved path if resolved, else an empty string.
 *
 * @since   4.0.0
 */
public function getUri($resolvePath = true) : string
{
    $path = $this->uri;
    if ($resolvePath && $path) {
        switch (pathinfo($path, PATHINFO_EXTENSION)) {
            case 'js':
                $path = $this->resolvePath($path, 'script');
                break;
            case 'css':
                $path = $this->resolvePath($path, 'stylesheet');
                break;
            default:
                break;
        }
    }
    return $path ?? '';
}