ContentBlock
in package
implements
ContentBlockInterface
uses
Serializable
Class to create nested blocks of content.
$innerBlock = ContentBlock::create(); $innerBlock->setContent('my inner content'); $outerBlock = ContentBlock::create(); $outerBlock->setContent(sprintf('Inside my outer block I have %s.', $innerBlock->getToken())); $outerBlock->addBlock($innerBlock); echo $outerBlock;
Table of Contents
Interfaces
- ContentBlockInterface
- ContentBlock Interface
Properties
- $blocks : array<string|int, mixed>
- $cached : bool
- $checksum : string
- $content : string
- $id : string
- $tokenTemplate : string
- $version : int
Methods
- __construct() : mixed
- Block constructor.
- __serialize() : array<string|int, mixed>
- __toString() : string
- __unserialize() : void
- addBlock() : $this
- build() : void
- create() : static
- disableCache() : $this
- fromArray() : ContentBlockInterface
- getChecksum() : string
- getId() : string
- getToken() : string
- isCached() : bool
- serialize() : string
- setChecksum() : $this
- setContent() : $this
- toArray() : array<string|int, mixed>
- toString() : string
- unserialize() : void
- checkVersion() : void
- generateId() : string
- getUnserializeAllowedClasses() : array<string|int, mixed>|bool
Properties
$blocks
protected
array<string|int, mixed>
$blocks
= []
$cached
protected
bool
$cached
= true
$checksum
protected
string
$checksum
$content
protected
string
$content
= ''
$id
protected
string
$id
$tokenTemplate
protected
string
$tokenTemplate
= '@@BLOCK-%s@@'
$version
protected
int
$version
= 1
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>
addBlock()
public
addBlock(ContentBlockInterface $block) : $this
Parameters
- $block : ContentBlockInterface
Return values
$thisbuild()
public
build(array<string|int, mixed> $serialized) : void
Parameters
- $serialized : array<string|int, mixed>
Tags
create()
public
static create([string|null $id = null ]) : static
Parameters
- $id : string|null = null
Return values
staticdisableCache()
public
disableCache() : $this
Return values
$thisfromArray()
public
static fromArray(array<string|int, mixed> $serialized) : ContentBlockInterface
Parameters
- $serialized : array<string|int, mixed>
Tags
Return values
ContentBlockInterfacegetChecksum()
public
getChecksum() : string
Return values
stringgetId()
public
getId() : string
Return values
stringgetToken()
public
getToken() : string
Return values
stringisCached()
public
isCached() : bool
Return values
boolserialize()
public
final serialize() : string
Return values
stringsetChecksum()
public
setChecksum(string $checksum) : $this
Parameters
- $checksum : string
Return values
$thissetContent()
public
setContent(string $content) : $this
Parameters
- $content : string
Return values
$thistoArray()
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>toString()
public
toString() : string
Return values
stringunserialize()
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
generateId()
protected
generateId() : string
Return values
stringgetUnserializeAllowedClasses()
protected
getUnserializeAllowedClasses() : array<string|int, mixed>|bool