Skip to content

Commit

Permalink
Fixed overriding extension templates in styles.
Browse files Browse the repository at this point in the history
  • Loading branch information
parpalak committed Apr 5, 2024
1 parent 60c4c50 commit 61be159
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions _include/src/Template/HtmlTemplateProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,23 +137,21 @@ static function ($matches) use ($requestUri) {

private function getTemplateFullFilename(?string $extraDir, string $cleanTemplateId): string
{
if ($extraDir !== null) {
$templatePathInExtension = $this->rootDir . '_extensions/' . $extraDir . '/templates/' . $cleanTemplateId;
if (file_exists($templatePathInExtension)) {
return $templatePathInExtension;
}
$pathInStyles = $this->rootDir . '_styles/' . $this->styleName . '/templates/' . $cleanTemplateId;
if (file_exists($pathInStyles)) {
return $pathInStyles;
}

$templatePathInStyles = $this->rootDir . '_styles/' . $this->styleName . '/templates/' . $cleanTemplateId;
if (file_exists($templatePathInStyles)) {
return $templatePathInStyles;
if ($extraDir !== null) {
$path = $this->rootDir . '_extensions/' . $extraDir . '/templates/' . $cleanTemplateId;
} else {
$path = $this->rootDir . '_include/templates/' . $cleanTemplateId;
}

$templateDefaultPath = $this->rootDir . '_include/templates/' . $cleanTemplateId;
if (file_exists($templateDefaultPath)) {
return $templateDefaultPath;
if (file_exists($path)) {
return $path;
}

throw new \RuntimeException(sprintf(\Lang::get('Template not found'), $templateDefaultPath));
throw new \RuntimeException(sprintf(\Lang::get('Template not found'), $path));
}
}

0 comments on commit 61be159

Please sign in to comment.