Documentation

InlineCss extends BaseAsset
in package

Class InlineCss

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
InlineCss 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

JS_MODULE_ASSET

protected mixed JS_MODULE_ASSET = 3

Properties

$attributes

protected array<string|int, mixed> $attributes = []

$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.

Methods

__construct()

InlineCss 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
throws
RuntimeException
Return values
$this

defProperty()

public defProperty(string $property, mixed $default) : $this
Parameters
$property : string

Object property to be defined.

$default : mixed

Default value.

Return values
$this

getAsset()

public getAsset() : string|false
Return values
string|false

getKey()

public getKey() : string
Return values
string

getNestedProperty()

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
bool

getType()

public getType([bool $prefix = true ]) : string
Parameters
$prefix : bool = true
Return values
string

hasNestedProperty()

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|false

integrityHash()

Receive asset location and return the SRI integrity hash

public static integrityHash(string $input) : string
Parameters
$input : string
Return values
string

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
bool

jsonSerialize()

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
string

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
throws
RuntimeException
Return values
$this

setPosition()

public setPosition(string $position) : $this
Parameters
$position : string
Return values
$this

setProperty()

public setProperty(string $property, mixed $value) : $this
Parameters
$property : string

Object property to be updated.

$value : mixed

New value.

Return values
$this

unsetNestedProperty()

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
throws
RuntimeException
Return values
$this

unsetProperty()

public unsetProperty(string $property) : $this
Parameters
$property : string

Object property to be unset.

Return values
$this

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
string

doGetProperty()

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
throws
InvalidArgumentException

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.

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
string

getElement()

protected getElement(string $property[, mixed|null $default = null ]) : mixed|null
Parameters
$property : string
$default : mixed|null = null
Return values
mixed|null

getElements()

protected getElements() : array<string|int, mixed>
Return values
array<string|int, mixed>

getTypePrefix()

protected getTypePrefix() : string
Return values
string

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
string

moveImports()

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
string

renderQueryString()

Render Querystring

protected renderQueryString([string|null $asset = null ]) : string
Parameters
$asset : string|null = null
Return values
string

setElements()

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
$this

        
On this page

Search results