Server IP : 104.21.14.103 / Your IP : 3.17.74.148 Web Server : LiteSpeed System : Linux business53.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64 User : giankuin ( 1871) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/self/root/proc/thread-self/root/proc/self/root/proc/self/root/proc/thread-self/root/home/giankuin/thietke365.net/wp-content/plugins/mailpoet/lib/Automation/Engine/Validation/AutomationRules/ |
Upload File : |
<?php declare(strict_types = 1); namespace MailPoet\Automation\Engine\Validation\AutomationRules; if (!defined('ABSPATH')) exit; use MailPoet\Automation\Engine\Data\Automation; use MailPoet\Automation\Engine\Exceptions; use MailPoet\Automation\Engine\Exceptions\InvalidStateException; use MailPoet\Automation\Engine\Registry; use MailPoet\Automation\Engine\Storage\AutomationStorage; use MailPoet\Automation\Engine\Validation\AutomationGraph\AutomationNode; use MailPoet\Automation\Engine\Validation\AutomationGraph\AutomationNodeVisitor; class UnknownStepRule implements AutomationNodeVisitor { /** @var Registry */ private $registry; /** @var AutomationStorage */ private $automationStorage; /** @var Automation|null|false */ private $cachedExistingAutomation = false; public function __construct( Registry $registry, AutomationStorage $automationStorage ) { $this->registry = $registry; $this->automationStorage = $automationStorage; } public function initialize(Automation $automation): void { $this->cachedExistingAutomation = false; } public function visitNode(Automation $automation, AutomationNode $node): void { $step = $node->getStep(); $registryStep = $this->registry->getStep($step->getKey()); // step not registered (e.g. plugin was deactivated) - allow saving it only if it hasn't changed if (!$registryStep) { $currentAutomation = $this->getCurrentAutomation($automation); $currentStep = $currentAutomation ? ($currentAutomation->getSteps()[$step->getId()] ?? null) : null; if (!$currentStep || $step->toArray() !== $currentStep->toArray()) { throw Exceptions::automationStepModifiedWhenUnknown($step); } } } public function complete(Automation $automation): void { } private function getCurrentAutomation(Automation $automation): ?Automation { try { $id = $automation->getId(); if ($this->cachedExistingAutomation === false) { $this->cachedExistingAutomation = $this->automationStorage->getAutomation($id); } } catch (InvalidStateException $e) { // for new automations, no automation ID is set $this->cachedExistingAutomation = null; } return $this->cachedExistingAutomation; } }