Skip to content

Commit

Permalink
Dev: call addFileReplacementInDB from templateManifest model
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Jul 13, 2017
1 parent 281610d commit 17c3157
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion application/models/TemplateManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,20 +227,37 @@ public function extendsFile($sFile)
// The CSS/JS file is a configuration one....
if(in_array($sFile, $aFiles)){
$this->addFileReplacementInManifest($sFile, $sExt);
$this->addFileReplacementInDB($sFile, $sExt);
}
}
}
return $this->getFilePath($sFile, $this);
}

/**
* Add a file replacement entry in DB
* It first tries to get the oTemplateConfigurations for this template (can be void if edited from template, can be numerous if survey local config)
* If it exists, it call $oTemplateConfiguration->oTemplateConfiguration($sFile, $sType) for each one of them
*
* @param string $sFile the file to replace
* @param string $sType css|js
*/
public function addFileReplacementInDB($sFile, $sType)
{
$oTemplateConfigurationModels = TemplateConfiguration::model()->findAllByAttributes(array('templates_name'), array(':templates_name' => $this->sTemplateName));
foreach($oTemplateConfigurationModels as $oTemplateConfigurationModel){
$oTemplateConfigurationModel->addFileReplacementInDB($sFile, $sType);
}
}

/**
* Add a file replacement entry
* eg: <filename replace="css/template.css">css/template.css</filename>
*
* @param string $sFile the file to replace
* @param string $sType css|js
*/
public function addFileReplacementInManifest($sFile, $sType)
private function addFileReplacementInManifest($sFile, $sType)
{
// First we get the XML file
libxml_disable_entity_loader(false);
Expand Down

0 comments on commit 17c3157

Please sign in to comment.