AssetBuilder
extends AutoService
in package
Class AssetBuilder
Tags
Table of Contents
Properties
- $cacheEnabled : mixed
Methods
- __construct() : mixed
- AssetBuilder constructor.
- build() : string
- Build the cached copy of an $asset.
- clear() : mixed
- Clear out any cache files.
- getCacheModes() : array<string|int, mixed>
- getPath() : string
- getUrl() : string
- isCacheEnabled() : bool
- isValidName() : bool
- Determine if $name is a well-formed asset name.
- pageRender() : array<string|int, mixed>
- (INTERNAL ONLY)
- pageRun() : mixed
- (INTERNAL ONLY)
- render() : array<string|int, mixed>
- Generate the content for a dynamic asset.
- setCacheEnabled() : AssetBuilder
- digest() : string
- Create a unique identifier for the $params.
- getCachePath() : string
- Determine the local path of a cache file.
- getCacheUrl() : string
- Determine the URL of a cache file.
Properties
$cacheEnabled
protected
mixed
$cacheEnabled
Methods
__construct()
AssetBuilder constructor.
public
__construct([mixed $cacheEnabled = NULL ]) : mixed
Parameters
- $cacheEnabled : mixed = NULL
build()
Build the cached copy of an $asset.
public
build(string $name, array<string|int, mixed> $params[, bool $force = FALSE ]) : string
Parameters
- $name : string
-
Ex: 'angular.json'.
- $params : array<string|int, mixed>
- $force : bool = FALSE
-
Build the asset anew, even if it already exists.
Tags
Return values
string —File name (relative to cache folder). Ex: 'angular.abcd1234abcd1234.json'.
clear()
Clear out any cache files.
public
clear([bool $removeDir = TRUE ]) : mixed
Parameters
- $removeDir : bool = TRUE
-
Should folder itself be removed too.
getCacheModes()
public
static getCacheModes() : array<string|int, mixed>
Return values
array<string|int, mixed> —Array(string $value => string $label).
getPath()
public
getPath(string $name[, array<string|int, mixed> $params = [] ]) : string
Parameters
- $name : string
-
Ex: 'angular.json'.
- $params : array<string|int, mixed> = []
Return values
string —URL. Ex: '/var/www/files/civicrm/dyn/angular.abcd1234abcd1234.json'.
getUrl()
public
getUrl(string $name[, array<string|int, mixed> $params = [] ]) : string
Parameters
- $name : string
-
Ex: 'angular.json'.
- $params : array<string|int, mixed> = []
Return values
string —URL. Ex: 'http://example.org/files/civicrm/dyn/angular.abcd1234abcd1234.json'.
isCacheEnabled()
public
isCacheEnabled() : bool
Return values
boolisValidName()
Determine if $name is a well-formed asset name.
public
isValidName(string $name) : bool
Parameters
- $name : string
Return values
boolpageRender()
(INTERNAL ONLY)
public
static pageRender(array<string|int, mixed> $get) : array<string|int, mixed>
Execute a page-request for civicrm/asset/builder
.
Parameters
- $get : array<string|int, mixed>
-
The _GET values.
Return values
array<string|int, mixed> —Array with keys:
- statusCode: int, ex 200.
- mimeType: string, ex 'text/html'.
- content: string, ex 'Hello world'.
pageRun()
(INTERNAL ONLY)
public
static pageRun() : mixed
Execute a page-request for civicrm/asset/builder
.
render()
Generate the content for a dynamic asset.
public
render(string $name[, array<string|int, mixed> $params = [] ]) : array<string|int, mixed>
Parameters
- $name : string
- $params : array<string|int, mixed> = []
Tags
Return values
array<string|int, mixed> —Array with keys:
- statusCode: int, ex: 200.
- mimeType: string, ex: 'text/html'.
- content: string, ex: 'Hello world'.
setCacheEnabled()
public
setCacheEnabled(bool|null $cacheEnabled) : AssetBuilder
Parameters
- $cacheEnabled : bool|null
Return values
AssetBuilderdigest()
Create a unique identifier for the $params.
protected
digest(string $name, array<string|int, mixed> $params) : string
This identifier is designed to avoid accidental cache collisions.
Parameters
- $name : string
- $params : array<string|int, mixed>
Return values
stringgetCachePath()
Determine the local path of a cache file.
protected
getCachePath([string|null $fileName = NULL ]) : string
Parameters
- $fileName : string|null = NULL
-
Ex: 'angular.abcd1234abcd1234.json'.
Return values
string —URL. Ex: '/var/www/files/civicrm/dyn/angular.abcd1234abcd1234.json'.
getCacheUrl()
Determine the URL of a cache file.
protected
getCacheUrl([string|null $fileName = NULL ]) : string
Parameters
- $fileName : string|null = NULL
-
Ex: 'angular.abcd1234abcd1234.json'.
Return values
string —URL. Ex: 'http://example.org/files/civicrm/dyn/angular.abcd1234abcd1234.json'.