From e7fa9eda65284ddec3c3e2efe59cbad7dca6a5b7 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 15 Jul 2020 09:33:54 +0200 Subject: [PATCH] Use configuration for enabling twig cache --- sources/application/TwigBase/Twig/TwigHelper.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sources/application/TwigBase/Twig/TwigHelper.php b/sources/application/TwigBase/Twig/TwigHelper.php index 9637d54d7..75baae6ef 100644 --- a/sources/application/TwigBase/Twig/TwigHelper.php +++ b/sources/application/TwigBase/Twig/TwigHelper.php @@ -7,6 +7,7 @@ namespace Combodo\iTop\Application\TwigBase\Twig; use IssueLog; +use MetaModel; use Twig\Environment; use Twig_Environment; use Twig_Error; @@ -22,10 +23,13 @@ class TwigHelper $oLoader = new Twig_Loader_Filesystem($sViewPath); $oTwig = new Twig_Environment($oLoader); Extension::RegisterTwigExtensions($oTwig); - $sLocalPath = utils::LocalPath($sViewPath); - $sLocalPath = str_replace('env-'.utils::GetCurrentEnvironment(), 'twig', $sLocalPath); - $sCachePath = utils::GetCachePath().$sLocalPath; - $oTwig->setCache($sCachePath); + if (MetaModel::GetConfig()->Get('apc_cache.enabled')) + { + $sLocalPath = utils::LocalPath($sViewPath); + $sLocalPath = str_replace('env-'.utils::GetCurrentEnvironment(), 'twig', $sLocalPath); + $sCachePath = utils::GetCachePath().$sLocalPath; + $oTwig->setCache($sCachePath); + } return $oTwig; }