class AssetBuilder

Class AssetBuilder

Properties

protected mixed $cacheEnabled

Methods

static array
getCacheModes()

No description

__construct($cacheEnabled = NULL)

AssetBuilder constructor.

bool
isValidName(string $name)

Determine if $name is a well-formed asset name.

string
getUrl(string $name, array $params = [])

No description

string
getPath(string $name, array $params = [])

No description

string
build(string $name, array $params, bool $force = FALSE)

Build the cached copy of an $asset.

array
render(string $name, array $params = [])

Generate the content for a dynamic asset.

clear()

Clear out any cache files.

string
getCachePath(string|NULL $fileName = NULL)

Determine the local path of a cache file.

string
getCacheUrl(string|NULL $fileName = NULL)

Determine the URL of a cache file.

string
digest(string $name, array $params)

Create a unique identifier for the $params.

string
encode(array $params)

Encode $params in a format that's optimized for shorter URLs.

array
decode(string $str)

No description

bool
isCacheEnabled()

No description

setCacheEnabled(bool|null $cacheEnabled)

No description

static 
pageRun()

(INTERNAL ONLY)

static array
pageRender(array $get)

(INTERNAL ONLY)

Details

at line 79
static array getCacheModes()

Return Value

array Array(string $value => string $label).

at line 96
__construct($cacheEnabled = NULL)

AssetBuilder constructor.

Parameters

$cacheEnabled

at line 113
bool isValidName(string $name)

Determine if $name is a well-formed asset name.

Parameters

string $name

Return Value

bool

at line 127
string getUrl(string $name, array $params = [])

Parameters

string $name Ex: 'angular.json'.
array $params

Return Value

string URL. Ex: 'http://example.org/files/civicrm/dyn/angular.abcd1234abcd1234.json'.

at line 155
string getPath(string $name, array $params = [])

Parameters

string $name Ex: 'angular.json'.
array $params

Return Value

string URL. Ex: '/var/www/files/civicrm/dyn/angular.abcd1234abcd1234.json'.

at line 177
string build(string $name, array $params, bool $force = FALSE)

Build the cached copy of an $asset.

Parameters

string $name Ex: 'angular.json'.
array $params
bool $force Build the asset anew, even if it already exists.

Return Value

string File name (relative to cache folder). Ex: 'angular.abcd1234abcd1234.json'.

Exceptions

UnknownAssetException

at line 211
array render(string $name, array $params = [])

Generate the content for a dynamic asset.

Parameters

string $name
array $params

Return Value

array Array with keys: - statusCode: int, ex: 200. - mimeType: string, ex: 'text/html'. - content: string, ex: 'Hello world'.

Exceptions

CRM_Core_Exception

at line 230
clear()

Clear out any cache files.

at line 243
protected string getCachePath(string|NULL $fileName = NULL)

Determine the local path of a cache file.

Parameters

string|NULL $fileName Ex: 'angular.abcd1234abcd1234.json'.

Return Value

string URL. Ex: '/var/www/files/civicrm/dyn/angular.abcd1234abcd1234.json'.

at line 259
protected string getCacheUrl(string|NULL $fileName = NULL)

Determine the URL of a cache file.

Parameters

string|NULL $fileName Ex: 'angular.abcd1234abcd1234.json'.

Return Value

string URL. Ex: 'http://example.org/files/civicrm/dyn/angular.abcd1234abcd1234.json'.

at line 275
protected string digest(string $name, array $params)

Create a unique identifier for the $params.

This identifier is designed to avoid accidental cache collisions.

Parameters

string $name
array $params

Return Value

string

at line 293
protected string encode(array $params)

Encode $params in a format that's optimized for shorter URLs.

Parameters

array $params

Return Value

string

at line 309
protected array decode(string $str)

Parameters

string $str

Return Value

array

at line 324
bool isCacheEnabled()

Return Value

bool

at line 332
AssetBuilder setCacheEnabled(bool|null $cacheEnabled)

Parameters

bool|null $cacheEnabled

Return Value

AssetBuilder

at line 342
static pageRun()

(INTERNAL ONLY)

Execute a page-request for civicrm/asset/builder.

at line 361
static array pageRender(array $get)

(INTERNAL ONLY)

Execute a page-request for civicrm/asset/builder.

Parameters

array $get The _GET values.

Return Value

array Array with keys: - statusCode: int, ex 200. - mimeType: string, ex 'text/html'. - content: string, ex 'Hello world'.