Link
extends BaseAsset
in package
Class Link
Table of Contents
Constants
- CSS_ASSET = 1
- JS_ASSET = 2
- JS_MODULE_ASSET = 3
Properties
- $asset : string|false
- $asset_type : string
- $attributes : array<string|int, mixed>
- $base_url : string
- $fetch_command : Closure|null
- $group : string
- $modified : int|false
- $order : int
- $position : string
- $priority : int
- $query : string
- $remote : bool
- $timestamp : string
- $type : string
- $_definedProperties : array<string|int, mixed>
- $_key : string
Methods
- __construct() : mixed
- Css 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
- getAsset() : string|false
- getKey() : string
- getNestedProperty() : mixed
- getProperty() : mixed
- getRemote() : bool
- getType() : string
- hasKey() : bool
- hasNestedProperty() : bool
- hasProperty() : bool
- init() : $this|false
- integrityHash() : string
- Receive asset location and return the SRI integrity hash
- 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.
- render() : string
- setNestedProperty() : $this
- setPosition() : $this
- setProperty() : $this
- unsetNestedProperty() : $this
- unsetProperty() : $this
- buildLocalLink() : string|false
- Build local links including grav asset shortcodes
- cssRewrite() : string
- Placeholder for AssetUtilsTrait method
- 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
Constants
CSS_ASSET
protected
mixed
CSS_ASSET
= 1
JS_ASSET
protected
mixed
JS_ASSET
= 2
JS_MODULE_ASSET
protected
mixed
JS_MODULE_ASSET
= 3
Properties
$asset
protected
string|false
$asset
$asset_type
protected
string
$asset_type
$attributes
protected
array<string|int, mixed>
$attributes
= []
$base_url
protected
string
$base_url
$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.
$group
protected
string
$group
$modified
protected
int|false
$modified
$order
protected
int
$order
$position
protected
string
$position
$priority
protected
int
$priority
$query
protected
string
$query
= ''
$remote
protected
bool
$remote
$timestamp
protected
string
$timestamp
$type
protected
static string
$type
$_definedProperties
private
array<string|int, mixed>
$_definedProperties
$_key
private
string
$_key
Methods
__construct()
Css 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
$thisgetAsset()
public
getAsset() : string|false
Return values
string|falsegetKey()
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.
getRemote()
public
getRemote() : bool
Return values
boolgetType()
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).
init()
public
init(string|false $asset, array<string|int, mixed> $options) : $this|false
Parameters
- $asset : string|false
- $options : array<string|int, mixed>
Return values
$this|falseintegrityHash()
Receive asset location and return the SRI integrity hash
public
static integrityHash(string $input) : string
Parameters
- $input : string
Return values
stringisRemoteLink()
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]
render()
public
render() : string
Return values
stringsetNestedProperty()
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
$thissetPosition()
public
setPosition(string $position) : $this
Parameters
- $position : string
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
$thisbuildLocalLink()
Build local links including grav asset shortcodes
protected
buildLocalLink(string $asset) : string|false
Parameters
- $asset : string
-
the asset string reference
Return values
string|false —the final link url to the asset
cssRewrite()
Placeholder for AssetUtilsTrait method
protected
cssRewrite(string $file, string $dir, bool $local) : string
Parameters
- $file : string
- $dir : string
- $local : bool
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