Files
piratepoet/mailpoet/lib/AdminPages/Pages/Automation.php
Jan Jakes 24111af58b Move template management to registry
[MAILPOET-5372]
2023-06-19 13:29:25 +02:00

60 lines
1.6 KiB
PHP

<?php declare(strict_types = 1);
namespace MailPoet\AdminPages\Pages;
use MailPoet\AdminPages\PageRenderer;
use MailPoet\Automation\Engine\Data\AutomationTemplate;
use MailPoet\Automation\Engine\Registry;
use MailPoet\Automation\Engine\Storage\AutomationStorage;
use MailPoet\Form\AssetsController;
use MailPoet\WP\Functions as WPFunctions;
class Automation {
/** @var AssetsController */
private $assetsController;
/** @var PageRenderer */
private $pageRenderer;
/** @var WPFunctions */
private $wp;
/** @var AutomationStorage */
private $automationStorage;
/** @var Registry */
private $registry;
public function __construct(
AssetsController $assetsController,
PageRenderer $pageRenderer,
WPFunctions $wp,
AutomationStorage $automationStorage,
Registry $registry
) {
$this->assetsController = $assetsController;
$this->pageRenderer = $pageRenderer;
$this->wp = $wp;
$this->automationStorage = $automationStorage;
$this->registry = $registry;
}
public function render() {
$this->assetsController->setupAutomationListingDependencies();
$this->pageRenderer->displayPage('automation.html', [
'locale_full' => $this->wp->getLocale(),
'api' => [
'root' => rtrim($this->wp->escUrlRaw($this->wp->restUrl()), '/'),
'nonce' => $this->wp->wpCreateNonce('wp_rest'),
],
'automationCount' => $this->automationStorage->getAutomationCount(),
'templates' => array_map(
function(AutomationTemplate $template): array {
return $template->toArray();
},
array_values($this->registry->getTemplates())
),
]);
}
}