Metrix provides a collection of events for extending its functionality. Modules and plugins can register event listeners, typically in their init()
methods, to modify Metrix’s behavior.
beforeSaveSource
event#The event that is triggered before a source is saved.
use verbb\metrix\events\SourceEvent;
use verbb\metrix\services\Sources;
use yii\base\Event;
Event::on(Sources::class, Sources::EVENT_BEFORE_SAVE_SOURCE, function(SourceEvent $event) {
$source = $event->source;
$isNew = $event->isNew;
// ...
});
afterSaveSource
event#The event that is triggered after a source is saved.
use verbb\metrix\events\SourceEvent;
use verbb\metrix\services\Sources;
use yii\base\Event;
Event::on(Sources::class, Sources::EVENT_AFTER_SAVE_SOURCE, function(SourceEvent $event) {
$source = $event->source;
$isNew = $event->isNew;
// ...
});
beforeDeleteSource
event#The event that is triggered before a source is deleted.
use verbb\metrix\events\SourceEvent;
use verbb\metrix\services\Sources;
use yii\base\Event;
Event::on(Sources::class, Sources::EVENT_BEFORE_DELETE_SOURCE, function(SourceEvent $event) {
$source = $event->source;
// ...
});
afterDeleteSource
event#The event that is triggered after a source is deleted.
use verbb\metrix\events\SourceEvent;
use verbb\metrix\services\Sources;
use yii\base\Event;
Event::on(Sources::class, Sources::EVENT_AFTER_DELETE_SOURCE, function(SourceEvent $event) {
$source = $event->source;
// ...
});
beforeSaveView
event#The event that is triggered before a view is saved.
use verbb\metrix\events\ViewEvent;
use verbb\metrix\services\Views;
use yii\base\Event;
Event::on(Views::class, Views::EVENT_BEFORE_SAVE_SOURCE, function(ViewEvent $event) {
$view = $event->view;
$isNew = $event->isNew;
// ...
});
afterSaveView
event#The event that is triggered after a view is saved.
use verbb\metrix\events\ViewEvent;
use verbb\metrix\services\Views;
use yii\base\Event;
Event::on(Views::class, Views::EVENT_AFTER_SAVE_SOURCE, function(ViewEvent $event) {
$view = $event->view;
$isNew = $event->isNew;
// ...
});
beforeDeleteView
event#The event that is triggered before a view is deleted.
use verbb\metrix\events\ViewEvent;
use verbb\metrix\services\Views;
use yii\base\Event;
Event::on(Views::class, Views::EVENT_BEFORE_DELETE_SOURCE, function(ViewEvent $event) {
$view = $event->view;
// ...
});
afterDeleteView
event#The event that is triggered after a view is deleted.
use verbb\metrix\events\ViewEvent;
use verbb\metrix\services\Views;
use yii\base\Event;
Event::on(Views::class, Views::EVENT_AFTER_DELETE_SOURCE, function(ViewEvent $event) {
$view = $event->view;
// ...
});
beforeSavePreset
event#The event that is triggered before a preset is saved.
use verbb\metrix\events\PresetEvent;
use verbb\metrix\services\Presets;
use yii\base\Event;
Event::on(Presets::class, Presets::EVENT_BEFORE_SAVE_SOURCE, function(PresetEvent $event) {
$preset = $event->preset;
$isNew = $event->isNew;
// ...
});
afterSavePreset
event#The event that is triggered after a preset is saved.
use verbb\metrix\events\PresetEvent;
use verbb\metrix\services\Presets;
use yii\base\Event;
Event::on(Presets::class, Presets::EVENT_AFTER_SAVE_SOURCE, function(PresetEvent $event) {
$preset = $event->preset;
$isNew = $event->isNew;
// ...
});
beforeDeletePreset
event#The event that is triggered before a preset is deleted.
use verbb\metrix\events\PresetEvent;
use verbb\metrix\services\Presets;
use yii\base\Event;
Event::on(Presets::class, Presets::EVENT_BEFORE_DELETE_SOURCE, function(PresetEvent $event) {
$preset = $event->preset;
// ...
});
afterDeletePreset
event#The event that is triggered after a preset is deleted.
use verbb\metrix\events\PresetEvent;
use verbb\metrix\services\Presets;
use yii\base\Event;
Event::on(Presets::class, Presets::EVENT_AFTER_DELETE_SOURCE, function(PresetEvent $event) {
$preset = $event->preset;
// ...
});
beforeSaveWidget
event#The event that is triggered before a widget is saved.
use verbb\metrix\events\WidgetEvent;
use verbb\metrix\services\Widgets;
use yii\base\Event;
Event::on(Widgets::class, Widgets::EVENT_BEFORE_SAVE_SOURCE, function(WidgetEvent $event) {
$widget = $event->widget;
$isNew = $event->isNew;
// ...
});
afterSaveWidget
event#The event that is triggered after a widget is saved.
use verbb\metrix\events\WidgetEvent;
use verbb\metrix\services\Widgets;
use yii\base\Event;
Event::on(Widgets::class, Widgets::EVENT_AFTER_SAVE_SOURCE, function(WidgetEvent $event) {
$widget = $event->widget;
$isNew = $event->isNew;
// ...
});
beforeDeleteWidget
event#The event that is triggered before a widget is deleted.
use verbb\metrix\events\WidgetEvent;
use verbb\metrix\services\Widgets;
use yii\base\Event;
Event::on(Widgets::class, Widgets::EVENT_BEFORE_DELETE_SOURCE, function(WidgetEvent $event) {
$widget = $event->widget;
// ...
});
afterDeleteWidget
event#The event that is triggered after a widget is deleted.
use verbb\metrix\events\WidgetEvent;
use verbb\metrix\services\Widgets;
use yii\base\Event;
Event::on(Widgets::class, Widgets::EVENT_AFTER_DELETE_SOURCE, function(WidgetEvent $event) {
$widget = $event->widget;
// ...
});