Ensure workflow was trashed before deleting it

[MAILPOET-4540]
This commit is contained in:
Jan Jakes
2022-10-14 10:01:32 +02:00
committed by David Remer
parent 1b20bf45dd
commit 506cb8b732
3 changed files with 30 additions and 0 deletions

View File

@@ -29,6 +29,7 @@ class Exceptions {
private const WORKFLOW_STEP_MODIFIED_WHEN_UNKNOWN = 'mailpoet_automation_workflow_step_modified_when_unknown';
private const WORKFLOW_NOT_VALID = 'mailpoet_automation_workflow_not_valid';
private const MISSING_REQUIRED_SUBJECTS = 'mailpoet_automation_missing_required_subjects';
private const WORKFLOW_NOT_TRASHED = 'mailpoet_automation_workflow_not_trashed';
public function __construct() {
throw new InvalidStateException(
@@ -204,4 +205,11 @@ class Exceptions {
)
);
}
public static function workflowNotTrashed(int $id): UnexpectedValueException {
return UnexpectedValueException::create()
->withErrorCode(self::WORKFLOW_NOT_TRASHED)
// translators: %d is the ID of the workflow.
->withMessage(sprintf(__("Can't delete workflow with ID '%d' because it was not trashed.", 'mailpoet'), $id));
}
}