AtLeastOneTriggerRule.php
3 years ago
ConsistentStepMapRule.php
3 years ago
NoCycleRule.php
2 years ago
NoDuplicateEdgesRule.php
2 years ago
NoJoinRule.php
2 years ago
NoUnreachableStepsRule.php
2 years ago
TriggerNeedsToBeFollowedByActionRule.php
2 years ago
TriggersUnderRootRule.php
2 years ago
UnknownStepRule.php
3 years ago
ValidStepArgsRule.php
3 years ago
ValidStepFiltersRule.php
2 years ago
ValidStepOrderRule.php
3 years ago
ValidStepRule.php
2 months ago
ValidStepValidationRule.php
3 years ago
index.php
3 years ago
ConsistentStepMapRule.php
34 lines
| 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 ConsistentStepMapRule implements AutomationNodeVisitor { |
| 14 | public const RULE_ID = 'consistent-step-map'; |
| 15 | |
| 16 | public function initialize(Automation $automation): void { |
| 17 | foreach ($automation->getSteps() as $id => $step) { |
| 18 | if ((string)$id !== $step->getId()) { |
| 19 | // translators: %1$s is the ID of the step, %2$s is its index in the steps object. |
| 20 | throw Exceptions::automationStructureNotValid( |
| 21 | sprintf(__("Step with ID '%1\$s' stored under a mismatched index '%2\$s'.", 'mailpoet'), $step->getId(), $id), |
| 22 | self::RULE_ID |
| 23 | ); |
| 24 | } |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | public function visitNode(Automation $automation, AutomationNode $node): void { |
| 29 | } |
| 30 | |
| 31 | public function complete(Automation $automation): void { |
| 32 | } |
| 33 | } |
| 34 |