PHP Class AssetCompress\View\Helper\AssetCompressHelper

Handle inclusion assets using the AssetCompress features for concatenating and compressing asset files.
Inheritance: extends Cake\View\Helper
Show file Open project: markstory/asset_compress

Public Properties

Property Type Description
$helpers array Helpers used.

Protected Properties

Property Type Description
$collection MiniAsset\AssetCollection AssetCollection for the current config set.
$config MiniAsset\AssetConfig Configuration object
$factory AssetCompress\Factory Factory for other AssetCompress objects.
$writer MiniAsset\Output\AssetWriter AssetWriter instance

Public Methods

Method Description
__construct ( Cake\View\View $view, array $settings = [] ) : void Constructor - finds and parses the ini file the plugin uses.
assetConfig ( AssetConfig $config = null ) : AssetConfig | null Modify the runtime configuration of the helper.
css ( string $file, array $options = [] ) : string Create a CSS file. Will generate link tags for either the dynamic build controller, or the generated file if it exists.
exists ( string $file ) : boolean Check if a build exists (is defined and have at least one file) in the ini file.
inlineCss ( string $file ) : string Create a CSS file. Will generate inline style tags in production, or reference the dynamic build file in development
inlineScript ( string $file ) : string Create an inline script tag for a script asset. Will generate inline script tags in production, or reference the dynamic build file in development.
script ( string $file, array $options = [] ) : A Create a script tag for a script asset. Will generate script tags for either the dynamic build controller, or the generated file if it exists.
url ( string $file = null, boolean | array $full = false ) : string Get the URL for a given asset name.

Protected Methods

Method Description
_addExt ( string $file, string $ext ) : string Adds an extension if the file doesn't already end with it.
_getBuildName ( AssetTarget $build ) : string Get the build file name.
_getRoute ( AssetTarget $file, string $base ) : string Get the dynamic build path for an asset.
_relativizePath ( string $path ) : string Converts an absolute path into a web relative one.
collection ( ) : AssetCollection Get the AssetCollection
factory ( ) : Factory Get the AssetCompress factory based on the config object.
writer ( ) : AssetWriter Get the AssetWriter

Method Details

__construct() public method

Constructor - finds and parses the ini file the plugin uses.
public __construct ( Cake\View\View $view, array $settings = [] ) : void
$view Cake\View\View The view instance to use.
$settings array The settings for the helper.
return void

_addExt() protected method

Adds an extension if the file doesn't already end with it.
protected _addExt ( string $file, string $ext ) : string
$file string Filename
$ext string Extension with .
return string

_getBuildName() protected method

Generates filenames that are intended for production use with statically generated files.
protected _getBuildName ( AssetTarget $build ) : string
$build MiniAsset\AssetTarget The build being resolved.
return string The resolved build name.

_getRoute() protected method

This generates URLs that work with the development dispatcher filter.
protected _getRoute ( AssetTarget $file, string $base ) : string
$file MiniAsset\AssetTarget The build file you want to make a url for.
$base string The base path to fetch a url with.
return string Generated URL.

_relativizePath() protected method

Converts an absolute path into a web relative one.
protected _relativizePath ( string $path ) : string
$path string The path to convert
return string A webroot relative string.

assetConfig() public method

Used as a get/set for the ini file values.
public assetConfig ( AssetConfig $config = null ) : AssetConfig | null
$config MiniAsset\AssetConfig The config instance to set.
return MiniAsset\AssetConfig | null Either the current config object or null.

collection() protected method

Get the AssetCollection
protected collection ( ) : AssetCollection
return MiniAsset\AssetCollection

css() public method

To create build files without configuration use addCss() Options: - All options supported by HtmlHelper::css() are supported. - raw - Set to true to get one link element for each file in the build.
public css ( string $file, array $options = [] ) : string
$file string A build target to include.
$options array An array of options for the stylesheet tag.
return string A stylesheet tag

exists() public method

Check if a build exists (is defined and have at least one file) in the ini file.
public exists ( string $file ) : boolean
$file string Name of the build that will be checked if exists.
return boolean True if the build file exists.

factory() protected method

Get the AssetCompress factory based on the config object.
protected factory ( ) : Factory
return AssetCompress\Factory

inlineCss() public method

To create build files without configuration use addCss() Options: - All options supported by HtmlHelper::css() are supported.
public inlineCss ( string $file ) : string
$file string A build target to include.
return string style tag

inlineScript() public method

To create build files without configuration use addScript() Options: - All options supported by HtmlHelper::css() are supported.
public inlineScript ( string $file ) : string
$file string A build target to include.
return string script tag

script() public method

To create build files without configuration use addScript() Options: - All options supported by HtmlHelper::css() are supported. - raw - Set to true to get one script element for each file in the build.
public script ( string $file, array $options = [] ) : A
$file string A build target to include.
$options array An array of options for the script tag.
return A script tag

url() public method

Takes an build filename, and returns the URL to that build file.
public url ( string $file = null, boolean | array $full = false ) : string
$file string The build file that you want a URL for.
$full boolean | array Whether or not the URL should have the full base path.
return string The generated URL.

writer() protected method

Get the AssetWriter
protected writer ( ) : AssetWriter
return MiniAsset\Output\AssetWriter

Property Details

$collection protected property

AssetCollection for the current config set.
protected AssetCollection,MiniAsset $collection
return MiniAsset\AssetCollection

$config protected property

Configuration object
protected AssetConfig,MiniAsset $config
return MiniAsset\AssetConfig

$factory protected property

Factory for other AssetCompress objects.
protected Factory,AssetCompress $factory
return AssetCompress\Factory

$helpers public property

Helpers used.
public array $helpers
return array

$writer protected property

AssetWriter instance
protected AssetWriter,MiniAsset\Output $writer
return MiniAsset\Output\AssetWriter