Add workflow validator service with workflow graph validation rules

[MAILPOET-4629]
This commit is contained in:
Jan Jakes
2022-09-14 16:27:45 +02:00
committed by David Remer
parent a3ea91adae
commit e220b70c78
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,36 @@
<?php declare(strict_types = 1);
namespace MailPoet\Automation\Engine\Validation;
use MailPoet\Automation\Engine\Data\Workflow;
use MailPoet\Automation\Engine\Validation\WorkflowGraph\WorkflowWalker;
use MailPoet\Automation\Engine\Validation\WorkflowRules\ConsistentStepMapRule;
use MailPoet\Automation\Engine\Validation\WorkflowRules\NoCycleRule;
use MailPoet\Automation\Engine\Validation\WorkflowRules\NoDuplicateEdgesRule;
use MailPoet\Automation\Engine\Validation\WorkflowRules\NoJoinRule;
use MailPoet\Automation\Engine\Validation\WorkflowRules\NoSplitRule;
use MailPoet\Automation\Engine\Validation\WorkflowRules\NoUnreachableStepsRule;
use MailPoet\Automation\Engine\Validation\WorkflowRules\TriggersUnderRootRule;
class WorkflowValidator {
/** @var WorkflowWalker */
private $workflowWalker;
public function __construct(
WorkflowWalker $workflowWalker
) {
$this->workflowWalker = $workflowWalker;
}
public function validate(Workflow $workflow): void {
$this->workflowWalker->walk($workflow, [
new NoUnreachableStepsRule(),
new ConsistentStepMapRule(),
new NoDuplicateEdgesRule(),
new TriggersUnderRootRule(),
new NoCycleRule(),
new NoJoinRule(),
new NoSplitRule(),
]);
}
}