Trigger workflow and step before save hooks

[MAILPOET-4515]
This commit is contained in:
Jan Jakes
2022-07-28 16:13:57 +02:00
committed by Veljko V
parent 87f35abf8b
commit da58a5c416
2 changed files with 18 additions and 1 deletions

View File

@ -5,15 +5,21 @@ namespace MailPoet\Automation\Engine\Builder;
use MailPoet\Automation\Engine\Data\Step;
use MailPoet\Automation\Engine\Data\Workflow;
use MailPoet\Automation\Engine\Exceptions;
use MailPoet\Automation\Engine\Hooks;
use MailPoet\Automation\Engine\Registry;
class UpdateStepsController {
/** @var Hooks */
private $hooks;
/** @var Registry */
private $registry;
public function __construct(
Hooks $hooks,
Registry $registry
) {
$this->hooks = $hooks;
$this->registry = $registry;
}
@ -33,12 +39,16 @@ class UpdateStepsController {
if (!$step) {
throw Exceptions::workflowStepNotFound($key);
}
return new Step(
$stepData = new Step(
$data['id'],
$data['type'],
$data['key'],
$data['next_step_id'] ?? null,
$data['args'] ?? null
);
$this->hooks->doWorkflowStepBeforeSave($stepData);
return $stepData;
}
}