Check that step implementation exists when saving workflow
[MAILPOET-4515]
This commit is contained in:
@ -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'],
|
||||
|
Reference in New Issue
Block a user