From 1b9eb223b0727d514b22c32b50f3146b0cf5d8b2 Mon Sep 17 00:00:00 2001 From: David Remer Date: Mon, 14 Nov 2022 09:06:16 +0200 Subject: [PATCH] Load templates late [MAILPOET-4788] --- .../Engine/Storage/AutomationTemplateStorage.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mailpoet/lib/Automation/Engine/Storage/AutomationTemplateStorage.php b/mailpoet/lib/Automation/Engine/Storage/AutomationTemplateStorage.php index c8345946ab..23054f0f3a 100644 --- a/mailpoet/lib/Automation/Engine/Storage/AutomationTemplateStorage.php +++ b/mailpoet/lib/Automation/Engine/Storage/AutomationTemplateStorage.php @@ -25,10 +25,12 @@ class AutomationTemplateStorage { ) { $this->builder = $builder; $this->wp = $wp; - $this->templates = $this->createTemplates(); } public function getTemplateBySlug(string $slug): ?AutomationTemplate { + if (!$this->templates) { + $this->templates = $this->createTemplates(); + } foreach ($this->templates as $template) { if ($template->getSlug() === $slug) { return $template; @@ -39,6 +41,9 @@ class AutomationTemplateStorage { /** @return AutomationTemplate[] */ public function getTemplates(int $category = null): array { + if (!$this->templates) { + $this->templates = $this->createTemplates(); + } if (!$category) { return $this->templates; }