Call step before save hook more safely and explicitly
[MAILPOET-4515]
This commit is contained in:
@ -5,21 +5,15 @@ namespace MailPoet\Automation\Engine\Builder;
|
|||||||
use MailPoet\Automation\Engine\Data\Step;
|
use MailPoet\Automation\Engine\Data\Step;
|
||||||
use MailPoet\Automation\Engine\Data\Workflow;
|
use MailPoet\Automation\Engine\Data\Workflow;
|
||||||
use MailPoet\Automation\Engine\Exceptions;
|
use MailPoet\Automation\Engine\Exceptions;
|
||||||
use MailPoet\Automation\Engine\Hooks;
|
|
||||||
use MailPoet\Automation\Engine\Registry;
|
use MailPoet\Automation\Engine\Registry;
|
||||||
|
|
||||||
class UpdateStepsController {
|
class UpdateStepsController {
|
||||||
/** @var Hooks */
|
|
||||||
private $hooks;
|
|
||||||
|
|
||||||
/** @var Registry */
|
/** @var Registry */
|
||||||
private $registry;
|
private $registry;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
Hooks $hooks,
|
|
||||||
Registry $registry
|
Registry $registry
|
||||||
) {
|
) {
|
||||||
$this->hooks = $hooks;
|
|
||||||
$this->registry = $registry;
|
$this->registry = $registry;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,15 +34,12 @@ class UpdateStepsController {
|
|||||||
throw Exceptions::workflowStepNotFound($key);
|
throw Exceptions::workflowStepNotFound($key);
|
||||||
}
|
}
|
||||||
|
|
||||||
$stepData = new Step(
|
return new Step(
|
||||||
$data['id'],
|
$data['id'],
|
||||||
$data['type'],
|
$data['type'],
|
||||||
$data['key'],
|
$data['key'],
|
||||||
$data['next_step_id'] ?? null,
|
$data['next_step_id'] ?? null,
|
||||||
$data['args'] ?? null
|
$data['args'] ?? null
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->hooks->doWorkflowStepBeforeSave($stepData);
|
|
||||||
return $stepData;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,9 @@ class UpdateWorkflowController {
|
|||||||
if (array_key_exists('steps', $data)) {
|
if (array_key_exists('steps', $data)) {
|
||||||
$this->validateWorkflowSteps($workflow, $data['steps']);
|
$this->validateWorkflowSteps($workflow, $data['steps']);
|
||||||
$this->updateStepsController->updateSteps($workflow, $data['steps']);
|
$this->updateStepsController->updateSteps($workflow, $data['steps']);
|
||||||
|
foreach ($workflow->getSteps() as $step) {
|
||||||
|
$this->hooks->doWorkflowStepBeforeSave($step);
|
||||||
|
}
|
||||||
$changed = true;
|
$changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user