\Charcoal\Ui\DashboardDashboardTrait

Provides an implementation of {@see \Charcoal\Ui\Dashboard\DashboardInterface}.

Summary

Methods
Properties
Constants
setWidgetCallback()
setWidgets()
addWidget()
widgets()
hasWidgets()
numWidgets()
No public properties found
No constants found
setWidgetBuilder()
sortWidgetsByPriority()
$widgetBuilder
N/A
No private methods found
$widgets
$widgetCallback
N/A

Properties

$widgetBuilder

$widgetBuilder : object

Store a widget builder instance.

Type

object

$widgetCallback

$widgetCallback : callable

A callback applied to each widget output by {@see self::widgets()}.

Type

callable

Methods

setWidgetCallback()

setWidgetCallback(callable|null  $callable) : \Charcoal\Ui\Dashboard\DashboardInterface

Set a callback to be applied to each widget output by {@see self::widgets()}.

Parameters

callable|null $callable

A callback to be applied to each widget or NULL to disable the callback.

Throws

\InvalidArgumentException

If the argument is not callable or NULL.

Returns

\Charcoal\Ui\Dashboard\DashboardInterface

Chainable

setWidgets()

setWidgets(array  $widgets) : \Charcoal\Ui\Dashboard\DashboardInterface

Set the dashboard's widgets.

Parameters

array $widgets

A collection of widgets.

Returns

\Charcoal\Ui\Dashboard\DashboardInterface

Chainable

addWidget()

addWidget(string  $widgetIdent, \Charcoal\Ui\UiItemInterface|array  $widget) : \Charcoal\Ui\Dashboard\DashboardInterface

Add a widget to the dashboard.

If a widget with the same $widgetIdent already exists, it will be overridden.

Parameters

string $widgetIdent

The widget identifier.

\Charcoal\Ui\UiItemInterface|array $widget

The widget object or structure.

Throws

\InvalidArgumentException

If the widget is invalid.

Returns

\Charcoal\Ui\Dashboard\DashboardInterface

Chainable

widgets()

widgets(callable  $widgetCallback = null) : array<mixed,\Charcoal\Ui\UiItemInterface>|\Charcoal\Ui\Dashboard\Generator

Retrieve the dashboard's widgets.

Parameters

callable $widgetCallback

A callback applied to each widget.

Returns

array<mixed,\Charcoal\Ui\UiItemInterface>|\Charcoal\Ui\Dashboard\Generator

hasWidgets()

hasWidgets() : boolean

Determine if the dashboard has any widgets.

Returns

boolean

numWidgets()

numWidgets() : integer

Count the number of widgets attached to the dashboard.

Returns

integer

setWidgetBuilder()

setWidgetBuilder(object  $builder) : \Charcoal\Ui\Dashboard\DashboardInterface

Set a widget builder.

Parameters

object $builder

The builder to create customized widget objects.

Throws

\InvalidArgumentException

If the argument is not a widget builder.

Returns

\Charcoal\Ui\Dashboard\DashboardInterface

Chainable

sortWidgetsByPriority()

sortWidgetsByPriority(mixed  $a, mixed  $b) : integer

Static comparison function used by {@see uasort()}.

Parameters

mixed $a

Widget A.

mixed $b

Widget B.

Returns

integer —

Sorting value: -1 or 1