Locator
Locates asset files in the project directory tree.
Searches in (in order):
- Remote URL (fetched and cached)
- assets/
- themes/
/assets/ - static/
- themes/
/static/
Table of Contents
Properties
Methods
- __construct() : mixed
- buildLocalizedPath() : string|null
- Builds a localized variant of a path (e.g. "style.css" → "style.fr.css").
- buildPathFromUrl() : string
- Builds a relative path from a URL.
- locate() : array{file: string, path: string}
- Returns local file path and updated path, or throw an exception.
- sanitize() : string
- Replaces some characters by '_'.
- getRemoteFileContent() : string
- Try to get remote file content.
- searchInDirectory() : array{file: string, path: string}|null
- Searches for a file (with optional localized variant) in a directory.
Properties
$builder
protected
Builder
$builder
$config
protected
Config
$config
Methods
__construct()
public
__construct(Builder $builder) : mixed
Parameters
- $builder : Builder
buildLocalizedPath()
Builds a localized variant of a path (e.g. "style.css" → "style.fr.css").
public
static buildLocalizedPath(string $path[, string|null $language = null ]) : string|null
Returns null if no localization is needed or possible.
Parameters
- $path : string
- $language : string|null = null
Return values
string|nullbuildPathFromUrl()
Builds a relative path from a URL.
public
static buildPathFromUrl(string $url) : string
Used for remote files.
Parameters
- $url : string
Return values
stringlocate()
Returns local file path and updated path, or throw an exception.
public
locate(string $path[, string|null $fallback = null ][, string|null $userAgent = null ][, string|null $language = null ]) : array{file: string, path: string}
If $fallback path is set, it will be used if the remote file is not found.
Parameters
- $path : string
- $fallback : string|null = null
- $userAgent : string|null = null
- $language : string|null = null
Tags
Return values
array{file: string, path: string}sanitize()
Replaces some characters by '_'.
public
static sanitize(string $string) : string
Parameters
- $string : string
Return values
stringgetRemoteFileContent()
Try to get remote file content.
private
getRemoteFileContent(string $path[, string|null $userAgent = null ]) : string
Returns file content or throw an exception.
Parameters
- $path : string
- $userAgent : string|null = null
Tags
Return values
stringsearchInDirectory()
Searches for a file (with optional localized variant) in a directory.
private
searchInDirectory(string $baseDir, string $path, string|null $localizedPath) : array{file: string, path: string}|null
Parameters
- $baseDir : string
- $path : string
- $localizedPath : string|null