Cecil

Locator

Locates asset files in the project directory tree.

Searches in (in order):

  1. Remote URL (fetched and cached)
  2. assets/
  3. themes//assets/
  4. static/
  5. themes//static/

Table of Contents

Properties

$builder  : Builder
$config  : Config

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

Methods

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|null

buildPathFromUrl()

Builds a relative path from a URL.

public static buildPathFromUrl(string $url) : string

Used for remote files.

Parameters
$url : string
Return values
string

locate()

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
throws
RuntimeException
Return values
array{file: string, path: string}

sanitize()

Replaces some characters by '_'.

public static sanitize(string $string) : string
Parameters
$string : string
Return values
string

getRemoteFileContent()

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
throws
RuntimeException
Return values
string

searchInDirectory()

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
Return values
array{file: string, path: string}|null
On this page

Search results