Reference

Preset

A Preset contains reusable Widget configurations. Obtain one from Metrix's Presets service when a module needs to inspect or assemble a dashboard preset:

$preset = \verbb\metrix\Metrix::$plugin->getPresets()->getPresetByHandle('websiteOverview');

if (!$preset) {
    throw new \RuntimeException('The websiteOverview Metrix Preset does not exist.');
}

Properties

id

Type: string|int|null

The unique identifier for the preset (when stored).

name

Type: string|null

The name of the preset.

handle

Type: string|null

The handle of the preset.

enabled

Type: bool

Whether the preset is enabled.

widgets

Type: array

Widget configs applied when the preset is used.

Methods

getWidgets(): array

Returns: array

Widget instances / configs for the preset.

setWidgets(array $widgetConfigs): void

Returns: void

Normalises and assigns Widget instances or configuration arrays.

$preset->setWidgets([
    [
        'type' => \verbb\metrix\widgets\Counter::class,
        'source' => 'analytics',
        'canonicalMetric' => 'visitors',
        'width' => 1,
    ],
]);

$widgets = $preset->getWidgets();
Last updated: Oct 10, 2026, 9:59:15 AM