Add workflow validator service with workflow graph validation rules
[MAILPOET-4629]
This commit is contained in:
@ -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(),
|
||||
]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user