class FilesystemMapper implements Mapper

Maps asset references to files within a specified local directory.

Supports versioning based on file modification time and optional extension auto-detection.

Methods

__construct(string $baseUrl, string $basePath, array $extensions = [])

No description

getAsset(string $reference, array $options = [])

Resolves a relative reference to a asset within the configured base path.

string
resolveUrl(string $reference)

Constructs the full public URL by prepending the base URL to the reference.

string
resolvePath(string $reference)

Constructs the full filesystem path by prepending the base path to the reference.

string
buildUrl(string $reference, array $options)

Builds the final public URL, potentially including a version query parameter.

string|null
getVersion(string $reference)

Determines the version string for an asset, typically based on file modification time.

string
applyVersion(string $url, string $version)

Appends the version string to the URL as a query parameter '?v=...'.

Details

at line 14
__construct(string $baseUrl, string $basePath, array $extensions = [])

No description

Parameters

string $baseUrl
string $basePath
array $extensions

at line 28
Asset getAsset(string $reference, array $options = [])

Resolves a relative reference to a asset within the configured base path.

Attempts to find a matching extension if configured.

Parameters

string $reference
array $options

Return Value

Asset

Exceptions

InvalidArgumentException
AssetNotFoundException

at line 45
string resolveUrl(string $reference)

Constructs the full public URL by prepending the base URL to the reference.

Parameters

string $reference

Return Value

string

at line 54
string resolvePath(string $reference)

Constructs the full filesystem path by prepending the base path to the reference.

Parameters

string $reference

Return Value

string

at line 63
protected string buildUrl(string $reference, array $options)

Builds the final public URL, potentially including a version query parameter.

Parameters

string $reference
array $options

Return Value

string

at line 76
protected string|null getVersion(string $reference)

Determines the version string for an asset, typically based on file modification time.

Parameters

string $reference

Return Value

string|null

at line 86
protected string applyVersion(string $url, string $version)

Appends the version string to the URL as a query parameter '?v=...'.

Parameters

string $url
string $version

Return Value

string