$abbreviation = ApplicationHandler::getInstance()->getActiveApplication()->getAbbreviation();
}
- return $this->compileDir.$this->templateGroupID.'_'.$abbreviation.'_'.$this->languageID.'_'.$templateName.'.php';
+ return $this->compileDir.$this->getTemplateGroupID().'_'.$abbreviation.'_'.$this->languageID.'_'.$templateName.'.php';
}
/**
- * @inheritDoc
+ * This method always throws, because changing the template group is not supported.
+ *
+ * @param integer $templateGroupID
+ * @throws \BadMethodCallException
*/
- public final function setTemplateGroupID($templateGroupID) {
- // template groups are not supported by the acp template engine
- $this->templateGroupID = 0;
+ public function setTemplateGroupID($templateGroupID) {
+ throw new \BadMethodCallException("You may not change the template group of the acp template engine");
}
/**
/**
* @inheritDoc
*/
- protected function init() {
- parent::init();
+ public function getTemplateGroupID() {
+ static $initialized = false;
- $sql = "SELECT templateGroupID
- FROM wcf".WCF_N."_template_group
- WHERE templateGroupFolderName = ?";
- $statement = WCF::getDB()->prepareStatement($sql);
- $statement->execute(['_wcf_email/']);
+ if (!$initialized) {
+ $sql = "SELECT templateGroupID
+ FROM wcf".WCF_N."_template_group
+ WHERE templateGroupFolderName = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute(['_wcf_email/']);
+
+ parent::setTemplateGroupID($statement->fetchSingleColumn());
+ }
- parent::setTemplateGroupID($statement->fetchSingleColumn());
+ return parent::getTemplateGroupID();
}
/**
* @return string
*/
protected function getPath($templatePath, $templateName) {
- $templateGroupID = $this->templateGroupID;
+ $templateGroupID = $this->getTemplateGroupID();
while ($templateGroupID != 0) {
$templateGroup = $this->templateGroupCache[$templateGroupID];
* @return string
*/
public function getCompiledFilename($templateName, $application) {
- return $this->compileDir.$this->templateGroupID.'_'.$application.'_'.$this->languageID.'_'.$templateName.'.php';
+ return $this->compileDir.$this->getTemplateGroupID().'_'.$application.'_'.$this->languageID.'_'.$templateName.'.php';
}
/**
* @return string
*/
public function getMetaDataFilename($templateName) {
- return $this->compileDir.$this->templateGroupID.'_'.$templateName.'.meta.php';
+ return $this->compileDir.$this->getTemplateGroupID().'_'.$templateName.'.meta.php';
}
/**