Do not handle workflow runs when workflow status is not active/deactivating

[MAILPOET-4731]
This commit is contained in:
David Remer
2022-10-24 11:28:36 +03:00
committed by Jan Jakeš
parent 627962570e
commit 2620ef0b57
3 changed files with 133 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ class Exceptions {
private const JSON_NOT_OBJECT = 'mailpoet_automation_json_not_object';
private const WORKFLOW_NOT_FOUND = 'mailpoet_automation_workflow_not_found';
private const WORKFLOW_VERSION_NOT_FOUND = 'mailpoet_automation_workflow_version_not_found';
private const WORKFLOW_NOT_ACTIVE = 'mailpoet_automation_workflow_not_active';
private const WORKFLOW_RUN_NOT_FOUND = 'mailpoet_automation_workflow_run_not_found';
private const WORKFLOW_STEP_NOT_FOUND = 'mailpoet_automation_workflow_step_not_found';
private const WORKFLOW_TRIGGER_NOT_FOUND = 'mailpoet_automation_workflow_trigger_not_found';
@@ -72,6 +73,13 @@ class Exceptions {
->withMessage(sprintf(__('Workflow with ID "%1$s" in version "%2$s" not found.', 'mailpoet'), $workflow, $version));
}
public static function workflowNotActive(int $workflow): InvalidStateException {
return InvalidStateException::create()
->withErrorCode(self::WORKFLOW_NOT_ACTIVE)
// translators: %1$s is the ID of the workflow.
->withMessage(sprintf(__('Workflow with ID "%1$s" in no longer active.', 'mailpoet'), $workflow));
}
public static function workflowRunNotFound(int $id): NotFoundException {
return NotFoundException::create()
->withErrorCode(self::WORKFLOW_RUN_NOT_FOUND)