Skip to content
Snippets Groups Projects
Commit e3b1abbc authored by Tim van Dijen's avatar Tim van Dijen
Browse files

Remove legacy code

parent d7f99a3f
No related branches found
No related tags found
No related merge requests found
...@@ -534,76 +534,6 @@ class Template extends Response ...@@ -534,76 +534,6 @@ class Template extends Response
} }
/**
* Find template path.
*
* This function locates the given template based on the template name. It will first search for the template in
* the current theme directory, and then the default theme.
*
* The template name may be on the form <module name>:<template path>, in which case it will search for the
* template file in the given module.
*
* @param string $template The relative path from the theme directory to the template file.
* @param bool $throw_exception
*
* @return string|null The absolute path to the template file.
*
* @throws \Exception If the template file couldn't be found.
*/
private function findTemplatePath(string $template, bool $throw_exception = true): ?string
{
list($templateModule, $templateName) = $this->findModuleAndTemplateName($template);
$templateModule = ($templateModule !== null) ? $templateModule : 'default';
// first check the current theme
if ($this->theme['module'] !== null) {
// .../module/<themeModule>/themes/<themeName>/<templateModule>/<templateName>
$filename = Module::getModuleDir($this->theme['module']) .
'/themes/' . $this->theme['name'] . '/' . $templateModule . '/' . $templateName;
} elseif ($templateModule !== 'default') {
// .../module/<templateModule>/templates/<templateName>
$filename = Module::getModuleDir($templateModule) . '/templates/' . $templateName;
} else {
// .../templates/<theme>/<templateName>
$base = $this->configuration->getPathValue('templatedir', 'templates/') ?: 'templates/';
$filename = $base . $templateName;
}
$filename = $this->normalizeTemplateName($filename);
// not found in current theme
Logger::debug(
$_SERVER['PHP_SELF'] . ' - Template: Could not find template file [' . $template . '] at [' .
$filename . '] - now trying the base template'
);
// try default theme
if ($templateModule !== 'default') {
// .../module/<templateModule>/templates/<templateName>
$filename = Module::getModuleDir($templateModule) . '/templates/' . $templateName;
} else {
// .../templates/<templateName>
$base = $this->configuration->getPathValue('templatedir', 'templates/') ?: 'templates/';
$filename = $base . '/' . $templateName;
}
$filename = $this->normalizeTemplateName($filename);
// not found in default template
if ($throw_exception) {
// log error and throw exception
$error = 'Template: Could not find template file [' . $template . '] at [' . $filename . ']';
Logger::critical($_SERVER['PHP_SELF'] . ' - ' . $error);
throw new \Exception($error);
} else {
// missing template expected, return NULL
return null;
}
}
/** /**
* Return the internal translator object used by this template. * Return the internal translator object used by this template.
* *
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment