Skip to content

Commit

Permalink
Dev: added static cache for method prepareTemplateRendering
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Dec 21, 2017
1 parent ae77503 commit 061112c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions application/models/TemplateConfiguration.php
Expand Up @@ -62,6 +62,9 @@ class TemplateConfiguration extends TemplateConfig
/** @var array $aInstancesFromTemplateName cache for method getInstanceFromTemplateName*/
public static $aInstancesFromTemplateName;

/** @var array $aInstancesFromTemplateName cache for method prepareTemplateRendering*/
public static $aPreparedToRender;

/** @var boolean $bTemplateCheckResult is the template valid?*/
private $bTemplateCheckResult;

Expand Down Expand Up @@ -379,11 +382,16 @@ public function checkTemplate()
*/
public function prepareTemplateRendering($sTemplateName = '', $iSurveyId = '', $bUseMagicInherit = true)
{
if (!empty(self::$aPreparedToRender[$sTemplateName][$iSurveyId][$bUseMagicInherit])){
return self::$aPreparedToRender[$sTemplateName][$iSurveyId][$bUseMagicInherit];
}

$this->bUseMagicInherit = $bUseMagicInherit;
$this->setBasics($sTemplateName, $iSurveyId);
$this->setMotherTemplates(); // Recursive mother templates configuration
$this->setThisTemplate(); // Set the main config values of this template
$this->createTemplatePackage($this); // Create an asset package ready to be loaded
self::$aPreparedToRender[$sTemplateName][$iSurveyId][$bUseMagicInherit] = $this;
return $this;
}

Expand Down

0 comments on commit 061112c

Please sign in to comment.