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
Type: string|int|null
The unique identifier for the preset (when stored).
Type: string|null
The name of the preset.
Type: string|null
The handle of the preset.
Type: bool
Whether the preset is enabled.
Type: array
Widget configs applied when the preset is used.
Methods
Returns: array
Widget instances / configs for the preset.
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