From 61be159070da54357e4dc884e479c2a2d4416484 Mon Sep 17 00:00:00 2001 From: Roman Parpalak Date: Fri, 5 Apr 2024 21:52:26 +0300 Subject: [PATCH] Fixed overriding extension templates in styles. --- .../src/Template/HtmlTemplateProvider.php | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/_include/src/Template/HtmlTemplateProvider.php b/_include/src/Template/HtmlTemplateProvider.php index 657aee6e..935c8447 100644 --- a/_include/src/Template/HtmlTemplateProvider.php +++ b/_include/src/Template/HtmlTemplateProvider.php @@ -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)); } }