PluginProbe
MailPoet – Newsletters, Email Marketing, and Automation / 5.33.1
MailPoet – Newsletters, Email Marketing, and Automation v5.33.1
5.38.0 5.37.0 5.36.1 5.36.0 5.35.1 5.35.0 5.34.3 5.34.2 5.34.1 5.34.0 5.33.1 5.33.0 5.32.0 5.31.0 5.30.0 5.29.0 5.28.1 5.28.0 5.27.0 5.26.0 5.26.1 5.25.0 5.24.0 4.43.0 4.43.1 All 542 releases
mailpoet / lib / Automation / Engine / Validation / AutomationRules / NoUnreachableStepsRule.php
NoUnreachableStepsRule.php
33 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php declare(strict_types = 1);
2
3 namespace MailPoet\Automation\Engine\Validation\AutomationRules;
4
5 if (!defined('ABSPATH')) exit;
6
7
8 use MailPoet\Automation\Engine\Data\Automation;
9 use MailPoet\Automation\Engine\Exceptions;
10 use MailPoet\Automation\Engine\Validation\AutomationGraph\AutomationNode;
11 use MailPoet\Automation\Engine\Validation\AutomationGraph\AutomationNodeVisitor;
12
13 class NoUnreachableStepsRule implements AutomationNodeVisitor {
14 public const RULE_ID = 'no-unreachable-steps';
15
16 /** @var AutomationNode[] */
17 private $visitedNodes = [];
18
19 public function initialize(Automation $automation): void {
20 $this->visitedNodes = [];
21 }
22
23 public function visitNode(Automation $automation, AutomationNode $node): void {
24 $this->visitedNodes[$node->getStep()->getId()] = $node;
25 }
26
27 public function complete(Automation $automation): void {
28 if (count($this->visitedNodes) !== count($automation->getSteps())) {
29 throw Exceptions::automationStructureNotValid(__('Unreachable steps found in automation graph', 'mailpoet'), self::RULE_ID);
30 }
31 }
32 }
33