Check that step implementation exists when saving workflow

[MAILPOET-4515]
This commit is contained in:
Jan Jakes
2022-07-28 13:33:08 +02:00
committed by Veljko V
parent cc2f908236
commit 2faf0739a3

View File

@ -4,8 +4,19 @@ 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\Registry;
class UpdateStepsController {
/** @var Registry */
private $registry;
public function __construct(
Registry $registry
) {
$this->registry = $registry;
}
public function updateSteps(Workflow $workflow, array $data): Workflow {
$steps = [];
foreach ($data as $stepData) {
@ -17,6 +28,11 @@ class UpdateStepsController {
}
private function processStep(array $data): Step {
$key = $data['key'];
$step = $this->registry->getStep($key);
if (!$step) {
throw Exceptions::workflowStepNotFound($key);
}
return new Step(
$data['id'],
$data['type'],