class Assets

Assets Class * Within controllers, widgets, components and views, use facade: Assets::addCss($path, $options); Assets::addJs($path, $options);

Traits

Properties

protected array $bundles from  CombinesAssets
protected array $filters from  CombinesAssets
protected string $storagePath from  CombinesAssets
bool $cacheKeyPrefix from  CombinesAssets
bool $useCache from  CombinesAssets
bool $useMinify from  CombinesAssets
protected $assetsCombinerUri from  CombinesAssets
protected $combineAssets from  CombinesAssets
static protected $registeredPaths
static protected $registeredCallback
protected $assets
protected $jsVarNamespace

Methods

initCombiner()

No description

string
combine(string $type, array $assets = [])

Combines JavaScript or StyleSheet file references to produce a page relative URL to the combined contents.

void
combineToFile(array $assets, string $destination)

Combines a collection of assets files to a destination file

combineGetContents($cacheKey)

No description

prepareAssets(array $assets)

No description

prepareCombiner(array $assets, $targetPath = null)

No description

string
getCombinerPath(string|null $path = null)

Returns the target path used with the combiner.

applyCacheOnFiles($files)

No description

registerFilter(string|array $extension, object $filter)

Register a filter to apply to the combining process.

void
registerBundle($extension, $files, null $destination = null, string $appContext = 'main')

Registers bundle.

array
getBundles(string $extension = null, string $appContext = 'main')

Returns bundles.

array
getFilters(string $extension = null)

Returns filters.

resetFilters(string $extension = null)

Clears any registered filters.

getCacheKey(array $assets)

No description

getCache($cacheKey)

No description

putCache($cacheKey, $cacheData)

No description

__construct()

No description

initialize()

No description

static 
registerCallback(callable $callback)

No description

void
registerSourcePath(string $path)

Set the default assets paths.

addFromManifest($path)

No description

addTags(array $tags = [])

No description

addTag($type, $tag, $options = [])

No description

getFavIcon()

No description

getMetas()

No description

getCss()

No description

getJs()

No description

getJsVars()

No description

addFavIcon($icon)

No description

addMeta(array $meta = [])

No description

addCss($path, $attributes = null)

No description

addJs($path, $attributes = null)

No description

putJsVars(array $variables)

No description

mergeJsVars($key, $value)

No description

flush()

No description

putAsset($type, $path, $attributes)

No description

getAsset($type)

No description

getAssetPath($name)

No description

filterAssetsToCombine($assets)

No description

array
getUniqueAssets($type)

Removes duplicate assets from the assets array.

prepUrl($path, $suffix = null)

No description

buildAssetUrls($type, $assets)

No description

buildAssetUrl($type, $file, $attributes = null)

No description

transformJsVar($value)

No description

transformJsObjectVar($value)

No description

Details

in CombinesAssets at line 55
protected initCombiner()

No description

in CombinesAssets at line 100
string combine(string $type, array $assets = [])

Combines JavaScript or StyleSheet file references to produce a page relative URL to the combined contents.

$assets = [ 'assets/css/vendor/animate.css', 'assets/css/vendor/dropzone.css', 'assets/css/vendor/select2.min.css', ];

Assets::combine('css', $assets);

Parameters

string $type
array $assets

Collection of assets

Return Value

string

URL to contents.

in CombinesAssets at line 143
void combineToFile(array $assets, string $destination)

Combines a collection of assets files to a destination file

$assets = [ 'assets/scss/flame.scss', 'assets/scss/main.scss', ];

CombineAssets::combineToFile( $assets, base_path('themes/demo/assets/css/theme.css'), );

Parameters

array $assets

Collection of assets

string $destination

Write the combined file to this location

Return Value

void

in CombinesAssets at line 156
combineGetContents($cacheKey)

No description

Parameters

$cacheKey

in CombinesAssets at line 186
protected prepareAssets(array $assets)

No description

Parameters

array $assets

in CombinesAssets at line 195
protected prepareCombiner(array $assets, $targetPath = null)

No description

Parameters

array $assets
$targetPath

in CombinesAssets at line 237
protected string getCombinerPath(string|null $path = null)

Returns the target path used with the combiner.

/index.php/_assets returns index-php/_assets/

Parameters

string|null $path

Return Value

string

The new target path

in CombinesAssets at line 250
protected applyCacheOnFiles($files)

No description

Parameters

$files

in CombinesAssets at line 282
CombinesAssets registerFilter(string|array $extension, object $filter)

Register a filter to apply to the combining process.

Parameters

string|array $extension

Extension name. Eg: css

object $filter

Collection of files to combine.

Return Value

CombinesAssets

in CombinesAssets at line 315
void registerBundle($extension, $files, null $destination = null, string $appContext = 'main')

Registers bundle.

Parameters

$extension
$files
null $destination
string $appContext

Return Value

void

in CombinesAssets at line 351
array getBundles(string $extension = null, string $appContext = 'main')

Returns bundles.

Parameters

string $extension
string $appContext

Return Value

array

in CombinesAssets at line 369
array getFilters(string $extension = null)

Returns filters.

Parameters

string $extension

Return Value

array

in CombinesAssets at line 387
CombinesAssets resetFilters(string $extension = null)

Clears any registered filters.

Parameters

string $extension

Return Value

CombinesAssets

in CombinesAssets at line 403
protected getCacheKey(array $assets)

No description

Parameters

array $assets

in CombinesAssets at line 410
protected getCache($cacheKey)

No description

Parameters

$cacheKey

in CombinesAssets at line 419
protected putCache($cacheKey, $cacheData)

No description

Parameters

$cacheKey
$cacheData

at line 30
__construct()

No description

at line 35
initialize()

No description

at line 46
static registerCallback(callable $callback)

No description

Parameters

callable $callback

at line 58
void registerSourcePath(string $path)

Set the default assets paths.

Parameters

string $path

Return Value

void

at line 63
addFromManifest($path)

No description

Parameters

$path

at line 83
addTags(array $tags = [])

No description

Parameters

array $tags

at line 101
addTag($type, $tag, $options = [])

No description

Parameters

$type
$tag
$options

at line 118
getFavIcon()

No description

at line 135
getMetas()

No description

at line 147
getCss()

No description

at line 152
getJs()

No description

at line 157
getJsVars()

No description

at line 174
addFavIcon($icon)

No description

Parameters

$icon

at line 181
addMeta(array $meta = [])

No description

Parameters

array $meta

at line 188
addCss($path, $attributes = null)

No description

Parameters

$path
$attributes

at line 195
addJs($path, $attributes = null)

No description

Parameters

$path
$attributes

at line 202
putJsVars(array $variables)

No description

Parameters

array $variables

at line 207
mergeJsVars($key, $value)

No description

Parameters

$key
$value

at line 216
flush()

No description

at line 221
protected putAsset($type, $path, $attributes)

No description

Parameters

$type
$path
$attributes

at line 226
protected getAsset($type)

No description

Parameters

$type

at line 244
protected getAssetPath($name)

No description

Parameters

$name

at line 260
protected filterAssetsToCombine($assets)

No description

Parameters

$assets

at line 281
protected array getUniqueAssets($type)

Removes duplicate assets from the assets array.

Parameters

$type

Return Value

array

at line 305
protected prepUrl($path, $suffix = null)

No description

Parameters

$path
$suffix

at line 315
protected buildAssetUrls($type, $assets)

No description

Parameters

$type
$assets

at line 327
protected buildAssetUrl($type, $file, $attributes = null)

No description

Parameters

$type
$file
$attributes

at line 352
protected transformJsVar($value)

No description

Parameters

$value

at line 357
protected transformJsObjectVar($value)

No description

Parameters

$value