Skip to content

Events ​

Alerts::EVENT_BEFORE_SEND ​

Triggered before an alert is sent, with an AlertEvent. Use it to send alerts somewhere else, or to change their text. Set $event->handled = true to stop Cron Guard sending the alert itself.

php
use suprim\cronguard\events\AlertEvent;
use suprim\cronguard\services\Alerts;
use yii\base\Event;

Event::on(Alerts::class, Alerts::EVENT_BEFORE_SEND, function(AlertEvent $event) {
    foreach ($event->problems as $problem) {
        // $problem['command'], $problem['state'], $problem['message'], $problem['reminder']
    }
});
Property
problemsCommands with a new problem, or one still there (reminder is true). Each has command, state, message, interval (seconds, or null), lastStart (a timestamp) and reminder.
recoveredCommands back to normal.
stoppedtrue when every scheduled command is late at once: cron has most likely stopped.
subject, textThe alert as emails and chat messages show it. Change them to change what's sent.
testtrue for a test alert.
handledSet to true to stop Cron Guard sending it.