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

The unique identifier for the preset, or null before it’s saved.

name

The name of the preset.

handle

The handle of the preset.

enabled

Whether the preset is enabled.

widgets

The widgets the preset adds to a View when it’s applied.

Methods

getWidgets()

Returns the preset’s widgets as widget objects.

setWidgets()

Arguments: array $widgetConfigs

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: Nov 13, 2026, 3:16:50 PM