Add hook and basic handler for automation triggers
For now trigger keys are stored in the workflow as a JSON array. This is not optimal in case someone has many workflows but as workflows are user-created it's unlinkely someone will have thousands of them. We can consider adding a workflow_triggers table as well. [MAILPOET-4136]
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace MailPoet\Automation\Engine;
|
||||
|
||||
use MailPoet\Automation\Engine\Exceptions\InvalidStateException;
|
||||
use MailPoet\Automation\Engine\Exceptions\NotFoundException;
|
||||
use MailPoet\Automation\Engine\Exceptions\UnexpectedValueException;
|
||||
|
||||
class Exceptions {
|
||||
@@ -10,6 +11,7 @@ class Exceptions {
|
||||
private const DATABASE_ERROR = 'mailpoet_automation_database_error';
|
||||
private const API_METHOD_NOT_ALLOWED = 'mailpoet_automation_api_method_not_allowed';
|
||||
private const API_NO_JSON_BODY = 'mailpoet_automation_api_no_json_body';
|
||||
private const WORKFLOW_TRIGGER_NOT_FOUND = 'mailpoet_automation_workflow_trigger_not_found';
|
||||
|
||||
public function __construct() {
|
||||
throw new InvalidStateException(
|
||||
@@ -41,4 +43,10 @@ class Exceptions {
|
||||
->withErrorCode(self::API_NO_JSON_BODY)
|
||||
->withMessage(__('No JSON body passed.', 'mailpoet'));
|
||||
}
|
||||
|
||||
public static function workflowTriggerNotFound(int $workflowId, string $key): NotFoundException {
|
||||
return NotFoundException::create()
|
||||
->withErrorCode(self::WORKFLOW_TRIGGER_NOT_FOUND)
|
||||
->withMessage(__(sprintf("Workflow trigger with key '%s' not found in workflow ID '%s'.", $key, $workflowId), 'mailpoet'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user