trait ManagesComponents

Constants

protected COMPONENT_STACK_CONTEXT_KEY

Context key for the components being rendered.

protected COMPONENT_DATA_CONTEXT_KEY

Context key for the original data passed to the component.

protected CURRENT_COMPONENT_DATA_CONTEXT_KEY

Context key for the component data for the component that is currently being rendered.

protected SLOTS_CONTEXT_KEY

Context key for the slot contents for the component.

protected SLOT_STACK_CONTEXT_KEY

Context key for the names of the slots being rendered.

Methods

void
startComponent(View|Htmlable|Closure|string $view, array $data = [])

Start a component rendering process.

int
pushComponentStack(View|Htmlable|Closure|string $view)

Push a component onto the stack.

View|Htmlable|Closure|string|null
popComponentStack()

Pop the current component from the stack.

void
appendComponentData(array $data)

Append data for the current component.

void
createSlotContext()

Create the slot context for the current component.

void
startComponentFirst(array $names, array $data = [])

Get the first view that actually exists from the given list, and start a component.

string
renderComponent()

Render the current component.

array
componentData()

Get the data for the given component.

mixed
getConsumableComponentData(string $key, mixed $default = null)

Get an item from the component data that exists above the current component.

void
slot(string $name, string|null $content = null, array $attributes = [])

Start the slot rendering process.

void
setSlotData(string $name, string|ComponentSlot|null $content)

Set slot data for the current component.

void
pushSlotStack(array $value)

Push a slot onto the stack.

array
popSlotStack()

Pop the current slot from the stack.

void
endSlot()

Save the slot content for rendering.

int
currentComponent()

Get the index for the current component.

void
flushComponents()

Flush all of the component state.

Details

at line 44
void startComponent(View|Htmlable|Closure|string $view, array $data = [])

Start a component rendering process.

Parameters

View|Htmlable|Closure|string $view
array $data

Return Value

void

at line 58
protected int pushComponentStack(View|Htmlable|Closure|string $view)

Push a component onto the stack.

Parameters

View|Htmlable|Closure|string $view

Return Value

int

at line 70
protected View|Htmlable|Closure|string|null popComponentStack()

Pop the current component from the stack.

Return Value

View|Htmlable|Closure|string|null

at line 82
protected void appendComponentData(array $data)

Append data for the current component.

Parameters

array $data

Return Value

void

at line 92
protected void createSlotContext()

Create the slot context for the current component.

Return Value

void

at line 102
void startComponentFirst(array $names, array $data = [])

Get the first view that actually exists from the given list, and start a component.

Parameters

array $names
array $data

Return Value

void

at line 114
string renderComponent()

Render the current component.

Return Value

string

at line 142
protected array componentData()

Get the data for the given component.

Return Value

array

at line 167
mixed getConsumableComponentData(string $key, mixed $default = null)

Get an item from the component data that exists above the current component.

Parameters

string $key
mixed $default

Return Value

mixed

at line 198
void slot(string $name, string|null $content = null, array $attributes = [])

Start the slot rendering process.

Parameters

string $name
string|null $content
array $attributes

Return Value

void

at line 212
protected void setSlotData(string $name, string|ComponentSlot|null $content)

Set slot data for the current component.

Parameters

string $name
string|ComponentSlot|null $content

Return Value

void

at line 224
protected void pushSlotStack(array $value)

Push a slot onto the stack.

Parameters

array $value

Return Value

void

at line 236
protected array popSlotStack()

Pop the current slot from the stack.

Return Value

array

at line 250
void endSlot()

Save the slot content for rendering.

Return Value

void

at line 265
protected int currentComponent()

Get the index for the current component.

Return Value

int

at line 274
protected void flushComponents()

Flush all of the component state.

Return Value

void