Slot
extends AbstractHelper
in package
Slot view helper
Tags
Table of Contents
- APPEND = 'APPEND'
- PREPEND = 'PREPEND'
- SET = 'SET'
- End saving methods
- $blockAppends : array<string|int, mixed>
- Storage for strings to be concatenated to the end of a block
- $blockPrepends : array<string|int, mixed>
- Storage for strings to be concatenated to the front of a block
- $blocks : array<string|int, mixed>
- Storage for strings saved to slots
- $stack : array<string|int, mixed>
- Call stack to handle nested slots
- __invoke() : Slot|string|mixed
- Get the Slot instance. Create if instance doesn't exist.
- __toString() : string|mixed
- Shortcut to get if no methods are called on invoke.
- append() : string
- Add string to list of block appends.
- clear() : void
- Unset any values stored in a slot.
- end() : string|mixed
- End a buffer capture to override the value of a block. Returns slot value.
- get() : string|null
- Get current value of slot. Returns null if unset.
- isset() : bool
- Checks for content to provide isset functionality.
- prepend() : string
- Add string to list of block prepends.
- set() : string|null
- Set current value of slot but only if unset.
- start() : void
- Starts a buffer capture to override the value of a block.
- build() : string|mixed
- Helper function to return blocks with prepends and appends.
Constants
APPEND
public
mixed
APPEND
= 'APPEND'
PREPEND
public
mixed
PREPEND
= 'PREPEND'
SET
End saving methods
public
mixed
SET
= 'SET'
Tags
Properties
$blockAppends
Storage for strings to be concatenated to the end of a block
protected
array<string|int, mixed>
$blockAppends
= []
of arrays
$blockPrepends
Storage for strings to be concatenated to the front of a block
protected
array<string|int, mixed>
$blockPrepends
= []
of arrays
$blocks
Storage for strings saved to slots
protected
array<string|int, mixed>
$blocks
= []
$stack
Call stack to handle nested slots
protected
array<string|int, mixed>
$stack
= []
Methods
__invoke()
Get the Slot instance. Create if instance doesn't exist.
public
__invoke(string $name[, mixed $value = null ]) : Slot|string|mixed
Parameters
- $name : string
-
Name of target block for action
- $value : mixed = null
-
Optional shortcut parameter to set a value
Return values
Slot|string|mixed —__toString()
Shortcut to get if no methods are called on invoke.
public
__toString() : string|mixed
Return values
string|mixed —append()
Add string to list of block appends.
public
append(string $value) : string
Parameters
- $value : string
-
Value to override if unset
Return values
string —clear()
Unset any values stored in a slot.
public
clear() : void
Return values
void —end()
End a buffer capture to override the value of a block. Returns slot value.
public
end([string $method = self::SET ]) : string|mixed
Parameters
- $method : string = self::SET
-
SET/PREPEND/APPEND for where this buffer should be saved
Return values
string|mixed —get()
Get current value of slot. Returns null if unset.
public
get([mixed $default = null ]) : string|null
Parameters
- $default : mixed = null
-
Value to return if no value is set
Return values
string|null —isset()
Checks for content to provide isset functionality.
public
isset() : bool
Return values
bool —prepend()
Add string to list of block prepends.
public
prepend(string $value) : string
Parameters
- $value : string
-
Value to override if unset
Return values
string —set()
Set current value of slot but only if unset.
public
set(mixed $value) : string|null
Parameters
- $value : mixed
-
Value to override if unset
Return values
string|null —start()
Starts a buffer capture to override the value of a block.
public
start() : void
Return values
void —build()
Helper function to return blocks with prepends and appends.
protected
build(string $name) : string|mixed
Prepends, blocks, and appends are separated byspacestopreventthisfromhappening
Non-string data can be stored in a slot but prepend and append will cause it to be concatenated into a string.
Parameters
- $name : string
-
Name of target block for action