Server IP : 172.67.158.161 / Your IP : 3.145.179.120 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/Builder/ |
Upload File : |
<?php declare(strict_types = 1); namespace MailPoet\Automation\Engine\Builder; 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\AutomationValidator; class CreateAutomationFromTemplateController { /** @var AutomationStorage */ private $storage; /** @var AutomationValidator */ private $automationValidator; /** @var Registry */ private $registry; public function __construct( AutomationStorage $storage, AutomationValidator $automationValidator, Registry $registry ) { $this->storage = $storage; $this->automationValidator = $automationValidator; $this->registry = $registry; } public function createAutomation(string $slug): Automation { $template = $this->registry->getTemplate($slug); if (!$template) { throw Exceptions::automationTemplateNotFound($slug); } $automation = $template->createAutomation(); $this->automationValidator->validate($automation); $automationId = $this->storage->createAutomation($automation); $savedAutomation = $this->storage->getAutomation($automationId); if (!$savedAutomation) { throw new InvalidStateException('Automation not found.'); } return $savedAutomation; } }