Documentation

HtmlBlock extends ContentBlock implements HtmlBlockInterface

HtmlBlock

Table of Contents

Interfaces

HtmlBlockInterface
Interface HtmlBlockInterface

Properties

$blocks  : array<string|int, mixed>
$cached  : bool
$checksum  : string
$content  : string
$frameworks  : array<string|int, mixed>
$html  : array<string|int, mixed>
$id  : string
$links  : array<string|int, mixed>
$scripts  : array<string|int, mixed>
$styles  : array<string|int, mixed>
$tokenTemplate  : string
$version  : int

Methods

__construct()  : mixed
Block constructor.
__serialize()  : array<string|int, mixed>
__toString()  : string
__unserialize()  : void
addBlock()  : $this
addFramework()  : $this
addHtml()  : bool
addInlineModule()  : bool
Shortcut for writing addInlineScript(['type' => 'module', 'content' => ...]).
addInlineScript()  : bool
addInlineStyle()  : bool
addLink()  : bool
addModule()  : bool
Shortcut for writing addScript(['type' => 'module', 'src' => ...]).
addScript()  : bool
addStyle()  : bool
build()  : void
create()  : static
disableCache()  : $this
fromArray()  : ContentBlockInterface
getAssets()  : array<string|int, mixed>
getChecksum()  : string
getFrameworks()  : array<string|int, mixed>
getHtml()  : array<string|int, mixed>
getId()  : string
getLinks()  : array<string|int, mixed>
getScripts()  : array<string|int, mixed>
getStyles()  : array<string|int, mixed>
getToken()  : string
isCached()  : bool
serialize()  : string
setChecksum()  : $this
setContent()  : $this
toArray()  : array<string|int, mixed>
toString()  : string
unserialize()  : void
checkVersion()  : void
generateId()  : string
getAssetsFast()  : array<string|int, mixed>
getAssetsInLocation()  : array<string|int, mixed>
getUnserializeAllowedClasses()  : array<string|int, mixed>|bool
sortAssets()  : void
sortAssetsInLocation()  : void

Properties

$frameworks

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

$html

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

$scripts

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

$styles

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

$tokenTemplate

protected string $tokenTemplate = '@@BLOCK-%s@@'

Methods

__construct()

Block constructor.

public __construct([string|null $id = null ]) : mixed
Parameters
$id : string|null = null

__serialize()

public final __serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

__toString()

public __toString() : string
Attributes
#[ReturnTypeWillChange]
Return values
string

__unserialize()

public final __unserialize(array<string|int, mixed> $data) : void
Parameters
$data : array<string|int, mixed>

addFramework()

public addFramework(string $framework) : $this
Parameters
$framework : string
Return values
$this

addHtml()

public addHtml(string $html[, int $priority = 0 ][, string $location = 'bottom' ]) : bool
Parameters
$html : string
$priority : int = 0
$location : string = 'bottom'
Return values
bool

addInlineModule()

Shortcut for writing addInlineScript(['type' => 'module', 'content' => ...]).

public addInlineModule(string|array<string|int, mixed> $element[, int $priority = 0 ][, string $location = 'head' ]) : bool
Parameters
$element : string|array<string|int, mixed>
$priority : int = 0
$location : string = 'head'
Return values
bool

addInlineScript()

public addInlineScript(string|array<string|int, mixed> $element[, int $priority = 0 ][, string $location = 'head' ]) : bool
Parameters
$element : string|array<string|int, mixed>
$priority : int = 0
$location : string = 'head'
Return values
bool

addInlineStyle()

public addInlineStyle(string|array<string|int, mixed> $element[, int $priority = 0 ][, string $location = 'head' ]) : bool
Parameters
$element : string|array<string|int, mixed>
$priority : int = 0
$location : string = 'head'
Return values
bool
public addLink(array<string|int, mixed> $element[, int $priority = 0 ][, string $location = 'head' ]) : bool
Parameters
$element : array<string|int, mixed>
$priority : int = 0
$location : string = 'head'
Return values
bool

addModule()

Shortcut for writing addScript(['type' => 'module', 'src' => ...]).

public addModule(string|array<string|int, mixed> $element[, int $priority = 0 ][, string $location = 'head' ]) : bool
Parameters
$element : string|array<string|int, mixed>
$priority : int = 0
$location : string = 'head'
Return values
bool

addScript()

public addScript(string|array<string|int, mixed> $element[, int $priority = 0 ][, string $location = 'head' ]) : bool
Parameters
$element : string|array<string|int, mixed>
$priority : int = 0
$location : string = 'head'
Return values
bool

addStyle()

public addStyle(string|array<string|int, mixed> $element[, int $priority = 0 ][, string $location = 'head' ]) : bool
Parameters
$element : string|array<string|int, mixed>
$priority : int = 0
$location : string = 'head'
Tags
example

$block->addStyle('assets/js/my.js');

example

$block->addStyle(['href' => 'assets/js/my.js', 'media' => 'screen']);

Return values
bool

build()

public build(array<string|int, mixed> $serialized) : void
Parameters
$serialized : array<string|int, mixed>
Tags
throws
RuntimeException

create()

public static create([string|null $id = null ]) : static
Parameters
$id : string|null = null
Return values
static

disableCache()

public disableCache() : $this
Return values
$this

getAssets()

public getAssets() : array<string|int, mixed>
Return values
array<string|int, mixed>

getChecksum()

public getChecksum() : string
Return values
string

getFrameworks()

public getFrameworks() : array<string|int, mixed>
Return values
array<string|int, mixed>

getHtml()

public getHtml([string $location = 'bottom' ]) : array<string|int, mixed>
Parameters
$location : string = 'bottom'
Return values
array<string|int, mixed>
public getLinks([string $location = 'head' ]) : array<string|int, mixed>
Parameters
$location : string = 'head'
Return values
array<string|int, mixed>

getScripts()

public getScripts([string $location = 'head' ]) : array<string|int, mixed>
Parameters
$location : string = 'head'
Return values
array<string|int, mixed>

getStyles()

public getStyles([string $location = 'head' ]) : array<string|int, mixed>
Parameters
$location : string = 'head'
Return values
array<string|int, mixed>

getToken()

public getToken() : string
Return values
string

serialize()

public final serialize() : string
Return values
string

setChecksum()

public setChecksum(string $checksum) : $this
Parameters
$checksum : string
Return values
$this

setContent()

public setContent(string $content) : $this
Parameters
$content : string
Return values
$this

toArray()

public toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

toString()

public toString() : string
Return values
string

unserialize()

public final unserialize(string $serialized) : void
Parameters
$serialized : string

checkVersion()

protected checkVersion(array<string|int, mixed> $serialized) : void
Parameters
$serialized : array<string|int, mixed>
Tags
throws
RuntimeException

generateId()

protected generateId() : string
Return values
string

getAssetsFast()

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

getAssetsInLocation()

protected getAssetsInLocation(string $type, string $location) : array<string|int, mixed>
Parameters
$type : string
$location : string
Return values
array<string|int, mixed>

getUnserializeAllowedClasses()

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

sortAssets()

protected sortAssets(array<string|int, mixed> &$array) : void
Parameters
$array : array<string|int, mixed>

sortAssetsInLocation()

protected sortAssetsInLocation(array<string|int, mixed> &$items) : void
Parameters
$items : array<string|int, mixed>

        
On this page

Search results