From 856176b75f59fcd25be0466223b49e493c85cac1 Mon Sep 17 00:00:00 2001 From: Kamil Date: Wed, 25 Dec 2019 16:17:00 +0500 Subject: [PATCH] Update SeriousTemplateProcessor.php Add caching aliases templates --- src/SeriousTemplateProcessor.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/SeriousTemplateProcessor.php b/src/SeriousTemplateProcessor.php index b861447..0b5181f 100644 --- a/src/SeriousTemplateProcessor.php +++ b/src/SeriousTemplateProcessor.php @@ -1,6 +1,5 @@ core->documentObject; if ($doc['template'] == 0) return $template; - $templateAlias = SiteTemplate::select('templatealias')->find($doc['template'])->templatealias; + if (EvolutionCMS()->getConfig('enable_cache')) { + $key = 'templates_id_alias'; + if (!$templates = \Cache::get($key)) { + $templates = SiteTemplate::all()->pluck('templatealias','id')->toArray(); + \Cache::forever($key, $templates); + } + $templateAlias = $templates[$doc['template']]; + } else { + $templateAlias = SiteTemplate::select('templatealias')->find($doc['template'])->templatealias; + } switch (true) { case $this->core['view']->exists('tpl-' . $doc['template'] . '_doc-' . $doc['id']): $template = 'tpl-' . $doc['template'] . '_doc-' . $doc['id'];