Events can be used to extend the functionality of Workflow.
beforeSaveSubmission
event#Plugins can get notified before a submission is saved. Event handlers can prevent the submission from getting sent by setting $event->isValid
to false.
use craft\events\ModelEvent;
use verbb\workflow\elements\Submission;
use yii\base\Event;
Event::on(Submission::class, Submission::EVENT_BEFORE_SAVE, function(ModelEvent $e) {
$submission = $event->sender;
$event->isValid = false;
});
afterSaveSubmission
event#Plugins can get notified after a submission has been saved
use craft\events\ModelEvent;
use verbb\workflow\elements\Submission;
use yii\base\Event;
Event::on(Submission::class, Submission::EVENT_AFTER_SAVE, function(ModelEvent $e) {
$submission = $event->sender;
});
afterGetReviewerUserGroups
event#Plugins can get notified when registering user groups for reviewers.
use verbb\workflow\events\ReviewerUserGroupsEvent;
use verbb\workflow\services\Submissions;
use yii\base\Event;
Event::on(Submissions::class, Submissions::EVENT_AFTER_GET_REVIEWER_USER_GROUPS, function(ReviewerUserGroupsEvent $e) {
$submission = $event->submission;
$userGroups = $event->userGroups;
});
prepareEditorEmail
event#The event that is triggered when preparing the editor email.
The isValid
event property can be set to false
to prevent the email from being sent.
use verbb\workflow\events\PrepareEmailEvent;
use verbb\workflow\services\Submissions;
use yii\base\Event;
Event::on(Submissions::class, Submissions::EVENT_PREPARE_EDITOR_EMAIL, function(PrepareEmailEvent $event) {
$editor = $event->editor;
$submission = $event->submission;
// ...
});
beforeSendEditorEmail
event#The event that is triggered before an email is sent to an editor.
The isValid
event property can be set to false
to prevent the email from being sent.
use verbb\workflow\events\EmailEvent;
use verbb\workflow\services\Submissions;
use yii\base\Event;
Event::on(Submissions::class, Submissions::EVENT_BEFORE_SEND_EDITOR_EMAIL, function(EmailEvent $event) {
$mail = $event->mail;
$user = $event->user;
$submission = $event->submission;
// ...
});
prepareReviewerEmail
event#The event that is triggered when preparing the reviewer email.
The isValid
event property can be set to false
to prevent the email from being sent.
use verbb\workflow\events\PrepareEmailEvent;
use verbb\workflow\services\Submissions;
use yii\base\Event;
Event::on(Submissions::class, Submissions::EVENT_PREPARE_REVIEWER_EMAIL, function(PrepareEmailEvent $event) {
$reviewers = $event->reviewers;
$submission = $event->submission;
// ...
});
beforeSendReviewerEmail
event#The event that is triggered before an email is sent to a reviewer.
The isValid
event property can be set to false
to prevent the email from being sent.
use verbb\workflow\events\EmailEvent;
use verbb\workflow\services\Submissions;
use yii\base\Event;
Event::on(Submissions::class, Submissions::EVENT_BEFORE_SEND_REVIEWER_EMAIL, function(EmailEvent $event) {
$mail = $event->mail;
$user = $event->user;
$submission = $event->submission;
// ...
});
preparePublisherEmail
event#The event that is triggered when preparing the publisher email.
The isValid
event property can be set to false
to prevent the email from being sent.
use verbb\workflow\events\PrepareEmailEvent;
use verbb\workflow\services\Submissions;
use yii\base\Event;
Event::on(Submissions::class, Submissions::EVENT_PREPARE_PUBLISHER_EMAIL, function(PrepareEmailEvent $event) {
$publishers = $event->publishers;
$submission = $event->submission;
// ...
});
beforeSendPublisherEmail
event#The event that is triggered before an email is sent to a publisher.
The isValid
event property can be set to false
to prevent the email from being sent.
use verbb\workflow\events\EmailEvent;
use verbb\workflow\services\Submissions;
use yii\base\Event;
Event::on(Submissions::class, Submissions::EVENT_BEFORE_SEND_PUBLISHER_EMAIL, function(EmailEvent $event) {
$mail = $event->mail;
$user = $event->user;
$submission = $event->submission;
// ...
});