interface AssetInterface (View source)

Interface that all the assets must implement.

Constants

ASSET_POSITION_HEADER

Asset position: in the tag.

ASSET_POSITION_FOOTER

Asset position: at the end of the tag.

OUTPUTASSETTYPE_CSS

Output asset type: CSS.

OUTPUTASSETTYPE_JAVASCRIPT

Output asset type: JavaScript.

OUTPUT_NOCACHE_PARAM

QueryString parameter to avoid browser cache problems.

Methods

string
__toString()

Render the HTML tag that will load this asset.

string
getAssetDefaultPosition()

Get the default asset position (\Concrete\Core\Asset\AssetInterface::ASSET_POSITION_HEADER or \Concrete\Core\Asset\AssetInterface::ASSET_POSITION_FOOTER).

setAssetPosition(string $position)

Set the position of this asset (\Concrete\Core\Asset\AssetInterface::ASSET_POSITION_HEADER or \Concrete\Core\Asset\AssetInterface::ASSET_POSITION_FOOTER).

string
getAssetPosition()

Get the position of this asset (\Concrete\Core\Asset\AssetInterface::ASSET_POSITION_HEADER or \Concrete\Core\Asset\AssetInterface::ASSET_POSITION_FOOTER).

string
getAssetType()

Get the unique identifier of the asset type.

string
getAssetHandle()

Get the handle of this asset (together with getAssetType, identifies this asset).

string
getOutputAssetType()

Get the resulting type of the asset (\Concrete\Core\Asset\AssetInterface::OUTPUTASSETTYPE_CSS, \Concrete\Core\Asset\AssetInterface::OUTPUTASSETTYPE_JAVASCRIPT or other values).

setAssetIsLocal(bool $isLocal)

Is this asset a locally available file (accessible with the getAssetPath method)?

bool
isAssetLocal()

Is this asset a locally available file (accessible with the getAssetPath method)?

setAssetSupportsMinification(bool $minify)

Does this asset support minification?

bool
assetSupportsMinification()

Does this asset support minification?

setAssetSupportsCombination(bool $combine)

Can this asset be combined with other assets?

bool
assetSupportsCombination()

Can this asset be combined with other assets?

setAssetURL(string $url)

Set the URL of this asset.

string
getAssetURL()

Get the URL of this asset.

setAssetPath(string $path)

Set the path to this asset.

string
getAssetPath()

Get the path to this asset.

mapAssetLocation(string $path)

If the asset is local, set its path and URL starting from the relative path. If it's not local, set its URL.

string
getAssetURLPath()

Get the path of the parent "folder" that contains this asset.

string
getAssetFilename()

Get the name of the file of this asset.

string
getAssetHashKey()

Get a string that unambiguously identifies this asset.

setAssetVersion(string $version)

Set the version of this asset.

string
getAssetVersion()

Get the version of this asset.

setPackageObject(Package|Package|null|false $pkg)

Set the package that defines this asset.

string|null
getAssetContents()

Get the contents of the asset (if applicable).

setCombinedAssetSourceFiles(string[] $paths)

Set the URL of the source files this asset has been built from (useful to understand the origin of this asset).

register(string $filename, array $args, Package|Package|string|null|false $pkg = false)

Register the asset properties.

static AssetInterface[]
process(AssetInterface[] $assets)

Asset-type specific post-processing.

Details

string __toString()

Render the HTML tag that will load this asset.

Return Value

string

string getAssetDefaultPosition()

Get the default asset position (\Concrete\Core\Asset\AssetInterface::ASSET_POSITION_HEADER or \Concrete\Core\Asset\AssetInterface::ASSET_POSITION_FOOTER).

Return Value

string

setAssetPosition(string $position)

Set the position of this asset (\Concrete\Core\Asset\AssetInterface::ASSET_POSITION_HEADER or \Concrete\Core\Asset\AssetInterface::ASSET_POSITION_FOOTER).

Parameters

string $position

string getAssetPosition()

Get the position of this asset (\Concrete\Core\Asset\AssetInterface::ASSET_POSITION_HEADER or \Concrete\Core\Asset\AssetInterface::ASSET_POSITION_FOOTER).

Return Value

string

string getAssetType()

Get the unique identifier of the asset type.

Return Value

string

string getAssetHandle()

Get the handle of this asset (together with getAssetType, identifies this asset).

Return Value

string

string getOutputAssetType()

Get the resulting type of the asset (\Concrete\Core\Asset\AssetInterface::OUTPUTASSETTYPE_CSS, \Concrete\Core\Asset\AssetInterface::OUTPUTASSETTYPE_JAVASCRIPT or other values).

Return Value

string

setAssetIsLocal(bool $isLocal)

Is this asset a locally available file (accessible with the getAssetPath method)?

Parameters

bool $isLocal

bool isAssetLocal()

Is this asset a locally available file (accessible with the getAssetPath method)?

Return Value

bool

setAssetSupportsMinification(bool $minify)

Does this asset support minification?

Parameters

bool $minify

bool assetSupportsMinification()

Does this asset support minification?

Return Value

bool

setAssetSupportsCombination(bool $combine)

Can this asset be combined with other assets?

Parameters

bool $combine

bool assetSupportsCombination()

Can this asset be combined with other assets?

Return Value

bool

setAssetURL(string $url)

Set the URL of this asset.

Parameters

string $url

string getAssetURL()

Get the URL of this asset.

Return Value

string

setAssetPath(string $path)

Set the path to this asset.

Parameters

string $path

string getAssetPath()

Get the path to this asset.

Return Value

string

mapAssetLocation(string $path)

If the asset is local, set its path and URL starting from the relative path. If it's not local, set its URL.

Parameters

string $path

string getAssetURLPath()

Get the path of the parent "folder" that contains this asset.

Return Value

string

string getAssetFilename()

Get the name of the file of this asset.

Return Value

string

string getAssetHashKey()

Get a string that unambiguously identifies this asset.

Return Value

string

setAssetVersion(string $version)

Set the version of this asset.

Parameters

string $version

string getAssetVersion()

Get the version of this asset.

Return Value

string

setPackageObject(Package|Package|null|false $pkg)

Set the package that defines this asset.

Parameters

Package|Package|null|false $pkg

string|null getAssetContents()

Get the contents of the asset (if applicable).

Return Value

string|null

setCombinedAssetSourceFiles(string[] $paths)

Set the URL of the source files this asset has been built from (useful to understand the origin of this asset).

Parameters

string[] $paths

register(string $filename, array $args, Package|Package|string|null|false $pkg = false)

Register the asset properties.

Parameters

string $filename

the location of the asset

array $args

{

@var bool $local is this asset a locally available file (accessible with the getAssetPath method)?
@var bool $minify does this asset support minification?
@var bool $combine can this asset be combined with other assets?
@var string $version the version of this asset
@var string $position the position of this asset (\Concrete\Core\Asset\AssetInterface::ASSET_POSITION_HEADER or \Concrete\Core\Asset\AssetInterface::ASSET_POSITION_FOOTER).

}

Package|Package|string|null|false $pkg

the package that defines this asset (or its handle)

static AssetInterface[] process(AssetInterface[] $assets)

Asset-type specific post-processing.

Parameters

AssetInterface[] $assets

The original assets

Return Value

AssetInterface[]

The final assets

Examples

Compress JavaScripts, merge CSS files...