Pipeline
extends PropertyObject
in package
uses
AssetUtilsTrait
Class Pipeline
Table of Contents
Constants
- CSS_ASSET = 1
- CSS_SOURCEMAP_REGEX = '{\/\*# (.*?) \*\/}'
- CSS_URL_REGEX = '{url\(([\'\"]?)(.*?)\1\)|(@import)\s+([\'\"])(.*?)\4}'
- FIRST_FORWARDSLASH_REGEX = '{^\/{1}\w}'
- JS_ASSET = 2
- JS_IMPORT_REGEX = '{import.+from\s?[\'|\"](.+?)[\'|\"]}'
- JS_MODULE_ASSET = 3
Properties
- $asset : string
- $assets_dir : string
- $assets_url : string
- $attributes : array<string|int, mixed>
- $base_url : string
- $css_minify : bool
- $css_minify_windows : bool
- $css_pipeline_include_externals : bool
- $css_rewrite : bool
- $fetch_command : Closure|null
- $js_minify : bool
- $js_minify_windows : bool
- $js_pipeline_include_externals : bool
- $query : string
- $timestamp : string
- $type : string
- $_definedProperties : array<string|int, mixed>
- $_key : string
Methods
- __construct() : mixed
- Pipeline constructor.
- __get() : mixed
- Returns the value at specified offset.
- __isset() : bool
- Checks whether or not an offset exists.
- __serialize() : array<string|int, mixed>
- __set() : void
- Assigns a value to the specified offset.
- __toString() : string
- Returns a string representation of this object.
- __unserialize() : void
- __unset() : void
- Magic method to unset the attribute
- defNestedProperty() : $this
- defProperty() : $this
- getKey() : string
- getNestedProperty() : mixed
- getProperty() : mixed
- getType() : string
- hasKey() : bool
- hasNestedProperty() : bool
- hasProperty() : bool
- isRemoteLink() : bool
- Determine whether a link is local or remote.
- jsonSerialize() : array<string|int, mixed>
- Implements JsonSerializable interface.
- offsetExists() : bool
- Whether or not an offset exists.
- offsetGet() : mixed
- Returns the value at specified offset.
- offsetSet() : void
- Assigns a value to the specified offset.
- offsetUnset() : void
- Unsets an offset.
- renderCss() : bool|string
- Minify and concatenate CSS
- renderJs() : bool|string
- Minify and concatenate JS files.
- renderJs_Module() : bool|string
- Minify and concatenate JS files.
- setNestedProperty() : $this
- setProperty() : $this
- unsetNestedProperty() : $this
- unsetProperty() : $this
- cssRewrite() : string
- Finds relative CSS urls() and rewrites the URL with an absolute one
- doGetProperty() : mixed
- doHasProperty() : bool
- doSerialize() : array<string|int, mixed>
- doSetProperty() : void
- doUnserialize() : void
- doUnsetProperty() : void
- gatherLinks() : string
- Download and concatenate the content of several links.
- getElement() : mixed|null
- getElements() : array<string|int, mixed>
- getTypePrefix() : string
- initObjectProperties() : void
- isPropertyLoaded() : bool
- jsRewrite() : string
- Finds relative JS urls() and rewrites the URL with an absolute one
- moveImports() : string
- Moves @import statements to the top of the file per the CSS specification
- offsetLoad() : mixed
- offsetPrepare() : mixed
- offsetSerialize() : mixed
- renderAttributes() : string
- Build an HTML attribute string from an array.
- renderQueryString() : string
- Render Querystring
- setElements() : void
- setKey() : $this
- shouldMinify() : bool
Constants
CSS_ASSET
protected
mixed
CSS_ASSET
= 1
CSS_SOURCEMAP_REGEX
protected
mixed
CSS_SOURCEMAP_REGEX
= '{\/\*# (.*?) \*\/}'
Tags
CSS_URL_REGEX
protected
mixed
CSS_URL_REGEX
= '{url\(([\'\"]?)(.*?)\1\)|(@import)\s+([\'\"])(.*?)\4}'
Tags
FIRST_FORWARDSLASH_REGEX
protected
mixed
FIRST_FORWARDSLASH_REGEX
= '{^\/{1}\w}'
JS_ASSET
protected
mixed
JS_ASSET
= 2
JS_IMPORT_REGEX
protected
mixed
JS_IMPORT_REGEX
= '{import.+from\s?[\'|\"](.+?)[\'|\"]}'
Tags
JS_MODULE_ASSET
protected
mixed
JS_MODULE_ASSET
= 3
Properties
$asset
protected
string
$asset
$assets_dir
protected
string
$assets_dir
$assets_url
protected
string
$assets_url
$attributes
protected
array<string|int, mixed>
$attributes
$base_url
protected
string
$base_url
$css_minify
protected
bool
$css_minify
= false
$css_minify_windows
protected
bool
$css_minify_windows
= false
$css_pipeline_include_externals
protected
bool
$css_pipeline_include_externals
= true
$css_rewrite
protected
bool
$css_rewrite
= false
$fetch_command
protected
Closure|null
$fetch_command
Closure used by the pipeline to fetch assets.
Useful when file_get_contents() function is not available in your PHP installation or when you want to apply any kind of preprocessing to your assets before they get pipelined.
The closure will receive as the only parameter a string with the path/URL of the asset and it should return the content of the asset file as a string.
$js_minify
protected
bool
$js_minify
= false
$js_minify_windows
protected
bool
$js_minify_windows
= false
$js_pipeline_include_externals
protected
bool
$js_pipeline_include_externals
= true
$query
protected
string
$query
= ''
$timestamp
protected
string
$timestamp
$type
protected
static string
$type
$_definedProperties
private
array<string|int, mixed>
$_definedProperties
$_key
private
string
$_key
Methods
__construct()
Pipeline constructor.
public
__construct([array<string|int, mixed> $elements = [] ][, string|null $key = null ]) : mixed
Parameters
- $elements : array<string|int, mixed> = []
- $key : string|null = null
__get()
Returns the value at specified offset.
public
__get(mixed $offset) : mixed
Parameters
- $offset : mixed
-
The offset to retrieve.
Attributes
- #[ReturnTypeWillChange]
Return values
mixed —Can return all value types.
__isset()
Checks whether or not an offset exists.
public
__isset(mixed $offset) : bool
Parameters
- $offset : mixed
-
An offset to check for.
Attributes
- #[ReturnTypeWillChange]
Return values
bool —Returns TRUE on success or FALSE on failure.
__serialize()
public
final __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>__set()
Assigns a value to the specified offset.
public
__set(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
-
The offset to assign the value to.
- $value : mixed
-
The value to set.
Attributes
- #[ReturnTypeWillChange]
__toString()
Returns a string representation of this object.
public
__toString() : string
Attributes
- #[ReturnTypeWillChange]
Return values
string__unserialize()
public
final __unserialize(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
__unset()
Magic method to unset the attribute
public
__unset(mixed $offset) : void
Parameters
- $offset : mixed
-
The name value to unset
Attributes
- #[ReturnTypeWillChange]
defNestedProperty()
public
defNestedProperty(string $property, mixed $default[, string|null $separator = null ]) : $this
Parameters
- $property : string
-
Object property to be updated.
- $default : mixed
-
Default value.
- $separator : string|null = null
-
Separator, defaults to '.'
Tags
Return values
$thisdefProperty()
public
defProperty(string $property, mixed $default) : $this
Parameters
- $property : string
-
Object property to be defined.
- $default : mixed
-
Default value.
Return values
$thisgetKey()
public
getKey() : string
Return values
stringgetNestedProperty()
public
getNestedProperty(string $property[, mixed|null $default = null ][, string|null $separator = null ]) : mixed
Parameters
- $property : string
-
Object property to be fetched.
- $default : mixed|null = null
-
Default value if property has not been set.
- $separator : string|null = null
-
Separator, defaults to '.'
Return values
mixed —Property value.
getProperty()
public
getProperty(string $property[, mixed $default = null ]) : mixed
Parameters
- $property : string
-
Object property to be fetched.
- $default : mixed = null
-
Default value if property has not been set.
Return values
mixed —Property value.
getType()
public
getType([bool $prefix = true ]) : string
Parameters
- $prefix : bool = true
Return values
stringhasKey()
public
hasKey() : bool
Return values
boolhasNestedProperty()
public
hasNestedProperty(string $property[, string|null $separator = null ]) : bool
Parameters
- $property : string
-
Object property name.
- $separator : string|null = null
-
Separator, defaults to '.'
Return values
bool —True if property has been defined (can be null).
hasProperty()
public
hasProperty(string $property) : bool
Parameters
- $property : string
-
Object property name.
Return values
bool —True if property has been defined (can be null).
isRemoteLink()
Determine whether a link is local or remote.
public
static isRemoteLink(string $link) : bool
Understands both "http://" and "https://" as well as protocol agnostic links "//"
Parameters
- $link : string
Return values
booljsonSerialize()
Implements JsonSerializable interface.
public
jsonSerialize() : array<string|int, mixed>
Attributes
- #[ReturnTypeWillChange]
Return values
array<string|int, mixed>offsetExists()
Whether or not an offset exists.
public
offsetExists(mixed $offset) : bool
Parameters
- $offset : mixed
-
An offset to check for.
Attributes
- #[ReturnTypeWillChange]
Return values
bool —Returns TRUE on success or FALSE on failure.
offsetGet()
Returns the value at specified offset.
public
offsetGet(mixed $offset) : mixed
Parameters
- $offset : mixed
-
The offset to retrieve.
Attributes
- #[ReturnTypeWillChange]
Return values
mixed —Can return all value types.
offsetSet()
Assigns a value to the specified offset.
public
offsetSet(mixed $offset, mixed $value) : void
Parameters
- $offset : mixed
-
The offset to assign the value to.
- $value : mixed
-
The value to set.
Attributes
- #[ReturnTypeWillChange]
offsetUnset()
Unsets an offset.
public
offsetUnset(mixed $offset) : void
Parameters
- $offset : mixed
-
The offset to unset.
Attributes
- #[ReturnTypeWillChange]
renderCss()
Minify and concatenate CSS
public
renderCss(array<string|int, mixed> $assets, string $group[, array<string|int, mixed> $attributes = [] ]) : bool|string
Parameters
- $assets : array<string|int, mixed>
- $group : string
- $attributes : array<string|int, mixed> = []
Return values
bool|string —URL or generated content if available, else false
renderJs()
Minify and concatenate JS files.
public
renderJs(array<string|int, mixed> $assets, string $group[, array<string|int, mixed> $attributes = [] ][, mixed $type = self::JS_ASSET ]) : bool|string
Parameters
- $assets : array<string|int, mixed>
- $group : string
- $attributes : array<string|int, mixed> = []
- $type : mixed = self::JS_ASSET
Return values
bool|string —URL or generated content if available, else false
renderJs_Module()
Minify and concatenate JS files.
public
renderJs_Module(array<string|int, mixed> $assets, string $group[, array<string|int, mixed> $attributes = [] ]) : bool|string
Parameters
- $assets : array<string|int, mixed>
- $group : string
- $attributes : array<string|int, mixed> = []
Return values
bool|string —URL or generated content if available, else false
setNestedProperty()
public
setNestedProperty(string $property, mixed $value[, string|null $separator = null ]) : $this
Parameters
- $property : string
-
Object property to be updated.
- $value : mixed
-
New value.
- $separator : string|null = null
-
Separator, defaults to '.'
Tags
Return values
$thissetProperty()
public
setProperty(string $property, mixed $value) : $this
Parameters
- $property : string
-
Object property to be updated.
- $value : mixed
-
New value.
Return values
$thisunsetNestedProperty()
public
unsetNestedProperty(string $property[, string|null $separator = null ]) : $this
Parameters
- $property : string
-
Object property to be updated.
- $separator : string|null = null
-
Separator, defaults to '.'
Tags
Return values
$thisunsetProperty()
public
unsetProperty(string $property) : $this
Parameters
- $property : string
-
Object property to be unset.
Return values
$thiscssRewrite()
Finds relative CSS urls() and rewrites the URL with an absolute one
protected
cssRewrite(string $file, string $dir, bool $local) : string
Parameters
- $file : string
-
the css source file
- $dir : string
-
, $local relative path to the css file
- $local : bool
-
is this a local or remote asset
Return values
stringdoGetProperty()
protected
& doGetProperty(string $property[, mixed $default = null ][, callable|bool $doCreate = false ]) : mixed
Parameters
- $property : string
-
Object property to be fetched.
- $default : mixed = null
-
Default value if property has not been set.
- $doCreate : callable|bool = false
-
Set true to create variable.
Return values
mixed —Property value.
doHasProperty()
protected
doHasProperty(string $property) : bool
Parameters
- $property : string
-
Object property name.
Return values
bool —True if property has been defined (can be null).
doSerialize()
protected
doSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed>doSetProperty()
protected
doSetProperty(string $property, mixed $value) : void
Parameters
- $property : string
-
Object property to be updated.
- $value : mixed
-
New value.
Tags
doUnserialize()
protected
doUnserialize(array<string|int, mixed> $serialized) : void
Parameters
- $serialized : array<string|int, mixed>
doUnsetProperty()
protected
doUnsetProperty(string $property) : void
Parameters
- $property : string
-
Object property to be unset.
gatherLinks()
Download and concatenate the content of several links.
protected
gatherLinks(array<string|int, mixed> $assets[, int $type = self::CSS_ASSET ]) : string
Parameters
- $assets : array<string|int, mixed>
- $type : int = self::CSS_ASSET
Return values
stringgetElement()
protected
getElement(string $property[, mixed|null $default = null ]) : mixed|null
Parameters
- $property : string
- $default : mixed|null = null
Return values
mixed|nullgetElements()
protected
getElements() : array<string|int, mixed>
Return values
array<string|int, mixed>getTypePrefix()
protected
getTypePrefix() : string
Return values
stringinitObjectProperties()
protected
initObjectProperties() : void
isPropertyLoaded()
protected
isPropertyLoaded(string $property) : bool
Parameters
- $property : string
-
Object property name.
Return values
bool —True if property has been loaded.
jsRewrite()
Finds relative JS urls() and rewrites the URL with an absolute one
protected
jsRewrite(string $file, string $dir, bool $local) : string
Parameters
- $file : string
-
the css source file
- $dir : string
-
local relative path to the css file
- $local : bool
-
is this a local or remote asset
Return values
stringmoveImports()
Moves @import statements to the top of the file per the CSS specification
protected
moveImports(string $file) : string
Parameters
- $file : string
-
the file containing the combined CSS files
Return values
string —the modified file with any @imports at the top of the file
offsetLoad()
protected
offsetLoad(string $offset, mixed $value) : mixed
Parameters
- $offset : string
- $value : mixed
offsetPrepare()
protected
offsetPrepare(string $offset, mixed $value) : mixed
Parameters
- $offset : string
- $value : mixed
offsetSerialize()
protected
offsetSerialize(string $offset, mixed $value) : mixed
Parameters
- $offset : string
- $value : mixed
renderAttributes()
Build an HTML attribute string from an array.
protected
renderAttributes() : string
Return values
stringrenderQueryString()
Render Querystring
protected
renderQueryString([string|null $asset = null ]) : string
Parameters
- $asset : string|null = null
Return values
stringsetElements()
protected
setElements(array<string|int, mixed> $elements) : void
Parameters
- $elements : array<string|int, mixed>
setKey()
protected
setKey(string $key) : $this
Parameters
- $key : string
Return values
$thisshouldMinify()
private
shouldMinify([string $type = 'css' ]) : bool
Parameters
- $type : string = 'css'