\Charcoal\Admin\UiNestedWidgetContainerTrait

An implementation, as Trait, of the {@see \Charcoal\Admin\Ui\NestedWidgetContainerInterface}.

Summary

Methods
Properties
Constants
widget()
getWidget()
setWidgetData()
mergeWidgetData()
addWidgetData()
widgetData()
defaultWidgetData()
widgetDataAsJson()
renderableData()
setRenderableData()
No public properties found
No constants found
createWidget()
resolveWidget()
renderDataRecursive()
renderData()
widgetFactory()
$widget
N/A
parseDataToken()
filterDataToken()
$widgetData
$renderableData
N/A

Properties

$widget

$widget : \Charcoal\App\Template\WidgetInterface

Store the nested widget.

Type

\Charcoal\App\Template\WidgetInterface

$widgetData

$widgetData : array

Settings for the nested widget.

Type

array

$renderableData

$renderableData : array

Settings, to be rendered, for the nested widget.

Type

array

Methods

widget()

widget() : \Charcoal\App\Template\WidgetInterface|\Charcoal\Admin\Ui\Generator

Yield the nested widget.

Returns

\Charcoal\App\Template\WidgetInterface|\Charcoal\Admin\Ui\Generator

getWidget()

getWidget() : \Charcoal\App\Template\WidgetInterface

Retrieve the nested widget.

Returns

\Charcoal\App\Template\WidgetInterface

setWidgetData()

setWidgetData(array  $settings) : self

Set the nested widget's options.

This method always merges default settings.

Parameters

array $settings

The nested widget options.

Returns

self

mergeWidgetData()

mergeWidgetData(array  $settings) : self

Merge (replacing or adding) nested widget options.

Parameters

array $settings

The nested widget options.

Returns

self

addWidgetData()

addWidgetData(string  $key, mixed  $val) : self

Add (or replace) an nested widget option.

Parameters

string $key

The setting to add/replace.

mixed $val

The setting's value to apply.

Throws

\InvalidArgumentException

If the identifier is not a string.

Returns

self

widgetData()

widgetData(string|null  $key = null, mixed|null  $default = null) : mixed

Retrieve the nested widget's options or a single option.

Parameters

string|null $key

The option key to lookup.

mixed|null $default

The fallback value to return if the $key doesn't exist.

Returns

mixed

defaultWidgetData()

defaultWidgetData() : array

Retrieve the default nested widget options.

Returns

array

widgetDataAsJson()

widgetDataAsJson() : string

Retrieve the nested widget's options as a JSON string.

Returns

string —

Returns data serialized with {@see json_encode()}.

renderableData()

renderableData() : array

Retrieve the nested widget's renderable options.

Returns

array

setRenderableData()

setRenderableData(array  $data) : self

Set the nested widget's renderable options.

Parameters

array $data

The data to render.

Returns

self

createWidget()

createWidget() : \Charcoal\App\Template\WidgetInterface

Create the nested widget.

Returns

\Charcoal\App\Template\WidgetInterface

resolveWidget()

resolveWidget(string  $type) : \Charcoal\App\Template\WidgetInterface

Resolve the nested widget.

Parameters

string $type

The widget to create.

Throws

\InvalidArgumentException

If the widget is invalid.

Returns

\Charcoal\App\Template\WidgetInterface

renderDataRecursive()

renderDataRecursive(array|\Traversable  $data) : array|\Traversable

Render the given data recursively.

Parameters

array|\Traversable $data

The data to render.

Throws

\InvalidArgumentException

If the data is not iterable.

\RuntimeException

If the form doesn't have a model.

Returns

array|\Traversable —

The rendered data.

renderData()

renderData(string  $data) : string

Render the given data.

Parameters

string $data

The data to render.

Returns

string —

The rendered data.

widgetFactory()

widgetFactory() : \Charcoal\Factory\FactoryInterface

Retrieve the widget factory.

Throws

\RuntimeException

If the widget factory was not previously set.

Returns

\Charcoal\Factory\FactoryInterface

parseDataToken()

parseDataToken(string|array  $token) : string

Parse the given slug (URI token) for the current object.

Parameters

string|array $token

The token to parse relative to the model entry.

Throws

\InvalidArgumentException

If a route token is not a string.

Returns

string

filterDataToken()

filterDataToken(mixed  $value, string  $token = null) : string

Filter the given value for a URI.

Parameters

mixed $value

A value to filter.

string $token

The parsed token.

Returns

string —

The filtered $value.