class Assets

A factory class for creating frontend asset compilers.

Properties

array $sources
protected array $lessImportOverrides
protected array $fileSourceOverrides

Methods

__construct(string $name, Cloud $assetsDir, string|null $cacheDir = null, array|null $lessImportDirs = null, array $customFunctions = [])

No description

js(callable $callback)

No description

css(callable $callback)

No description

localeJs(callable $callback)

No description

localeCss(callable $callback)

No description

jsDirectory(callable $callback)

No description

makeJs()

No description

makeCss()

No description

makeLocaleJs(string $locale)

No description

makeLocaleCss(string $locale)

No description

makeJsCompiler(string $filename)

No description

makeLessCompiler(string $filename)

No description

string|null
fontsDir()

Where the webfonts referenced by the compiled CSS live on disk, so their URLs can be revisioned. Font URLs are written relative to the stylesheet that imports them (`../webfonts/…`), so the fonts sit beside each LESS import directory — that is the same directory the assets publisher copies into `assets/fonts`.

string|null
fontRevision(string $file)

The revision the compiled stylesheet puts on a webfont's URL (`?v=…`), or null when the font can't be read. Anything else that links to a bundled font, like the font preloads, must use it: a preload is only used when its URL is exactly the one the stylesheet requests.

makeJsDirectoryCompiler(string $string)

No description

string
getName()

No description

void
setName(string $name)

No description

getAssetsDir()

No description

void
setAssetsDir( Cloud $assetsDir)

No description

string|null
getCacheDir()

No description

void
setCacheDir(string|null $cacheDir)

No description

array
getLessImportDirs()

No description

void
setLessImportDirs(array $lessImportDirs)

No description

void
addLessImportOverrides(array $lessImportOverrides)

No description

void
addFileSourceOverrides(array $fileSourceOverrides)

No description

Details

__construct(string $name, Cloud $assetsDir, string|null $cacheDir = null, array|null $lessImportDirs = null, array $customFunctions = [])

Parameters

string $name
Cloud $assetsDir
string|null $cacheDir
array|null $lessImportDirs
array $customFunctions

Assets js(callable $callback)

Parameters

callable $callback

Return Value

Assets

Assets css(callable $callback)

Parameters

callable $callback

Return Value

Assets

Assets localeJs(callable $callback)

Parameters

callable $callback

Return Value

Assets

Assets localeCss(callable $callback)

Parameters

callable $callback

Return Value

Assets

Assets jsDirectory(callable $callback)

Parameters

callable $callback

Return Value

Assets

JsCompiler makeJs()

Return Value

JsCompiler

LessCompiler makeCss()

Return Value

LessCompiler

JsCompiler makeLocaleJs(string $locale)

Parameters

string $locale

Return Value

JsCompiler

LessCompiler makeLocaleCss(string $locale)

Parameters

string $locale

Return Value

LessCompiler

JsDirectoryCompiler makeJsDirectory()

Return Value

JsDirectoryCompiler

protected JsCompiler makeJsCompiler(string $filename)

Parameters

string $filename

Return Value

JsCompiler

protected LessCompiler makeLessCompiler(string $filename)

Parameters

string $filename

Return Value

LessCompiler

protected string|null fontsDir()

Where the webfonts referenced by the compiled CSS live on disk, so their URLs can be revisioned. Font URLs are written relative to the stylesheet that imports them (`../webfonts/…`), so the fonts sit beside each LESS import directory — that is the same directory the assets publisher copies into `assets/fonts`.

Return Value

string|null

string|null fontRevision(string $file)

The revision the compiled stylesheet puts on a webfont's URL (`?v=…`), or null when the font can't be read. Anything else that links to a bundled font, like the font preloads, must use it: a preload is only used when its URL is exactly the one the stylesheet requests.

Cached, since the preloads are built on every page view and the hash only changes with the file. The key includes the file's size and modification time, so a replaced font gets its new revision straight away.

Parameters

string $file

Return Value

string|null

protected JsDirectoryCompiler makeJsDirectoryCompiler(string $string)

Parameters

string $string

Return Value

JsDirectoryCompiler

string getName()

Return Value

string

void setName(string $name)

Parameters

string $name

Return Value

void

Cloud getAssetsDir()

Return Value

Cloud

void setAssetsDir( Cloud $assetsDir)

Parameters

Cloud $assetsDir

Return Value

void

string|null getCacheDir()

Return Value

string|null

void setCacheDir(string|null $cacheDir)

Parameters

string|null $cacheDir

Return Value

void

array getLessImportDirs()

Return Value

array

void setLessImportDirs(array $lessImportDirs)

Parameters

array $lessImportDirs

Return Value

void

void addLessImportOverrides(array $lessImportOverrides)

Parameters

array $lessImportOverrides

Return Value

void

void addFileSourceOverrides(array $fileSourceOverrides)

Parameters

array $fileSourceOverrides

Return Value

void