Load templates late
[MAILPOET-4788]
This commit is contained in:
@@ -25,10 +25,12 @@ class AutomationTemplateStorage {
|
|||||||
) {
|
) {
|
||||||
$this->builder = $builder;
|
$this->builder = $builder;
|
||||||
$this->wp = $wp;
|
$this->wp = $wp;
|
||||||
$this->templates = $this->createTemplates();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTemplateBySlug(string $slug): ?AutomationTemplate {
|
public function getTemplateBySlug(string $slug): ?AutomationTemplate {
|
||||||
|
if (!$this->templates) {
|
||||||
|
$this->templates = $this->createTemplates();
|
||||||
|
}
|
||||||
foreach ($this->templates as $template) {
|
foreach ($this->templates as $template) {
|
||||||
if ($template->getSlug() === $slug) {
|
if ($template->getSlug() === $slug) {
|
||||||
return $template;
|
return $template;
|
||||||
@@ -39,6 +41,9 @@ class AutomationTemplateStorage {
|
|||||||
|
|
||||||
/** @return AutomationTemplate[] */
|
/** @return AutomationTemplate[] */
|
||||||
public function getTemplates(int $category = null): array {
|
public function getTemplates(int $category = null): array {
|
||||||
|
if (!$this->templates) {
|
||||||
|
$this->templates = $this->createTemplates();
|
||||||
|
}
|
||||||
if (!$category) {
|
if (!$category) {
|
||||||
return $this->templates;
|
return $this->templates;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user