From e70be941d5a78b909907a7d0a4c3111efb9127d6 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Mon, 7 Oct 2024 15:49:47 +1300 Subject: [PATCH] ENH Update code to reflect changes in template layer --- .../GridFieldDetailFormPreviewExtension.php | 3 +-- code/LeftAndMain.php | 23 +++++++++---------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/code/Forms/GridFieldDetailFormPreviewExtension.php b/code/Forms/GridFieldDetailFormPreviewExtension.php index 68d87c346..1ae028bd0 100644 --- a/code/Forms/GridFieldDetailFormPreviewExtension.php +++ b/code/Forms/GridFieldDetailFormPreviewExtension.php @@ -35,7 +35,6 @@ private function getSilverStripeNavigator(): DBHTMLText { $navigator = SilverStripeNavigator::create($this->owner->getRecord()); $templates = SSViewer::get_templates_by_class(LeftAndMain::class, '_SilverStripeNavigator', LeftAndMain::class); - $renderWith = SSViewer::chooseTemplate($templates); - return $navigator->renderWith($renderWith); + return $navigator->renderWith($templates); } } diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index 9eb920f7b..96e3e0c1a 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -1200,16 +1200,12 @@ public function MenuCurrentItem() } /** - * Return appropriate template(s) for this class, with the given suffix using + * Return appropriate template candidates for this class, with the given suffix using * {@link SSViewer::get_templates_by_class()} - * - * @param string $suffix - * @return string|array */ - public function getTemplatesWithSuffix($suffix) + public function getTemplatesWithSuffix(string $suffix): array { - $templates = SSViewer::get_templates_by_class(get_class($this), $suffix, __CLASS__); - return SSViewer::chooseTemplate($templates); + return SSViewer::get_templates_by_class(get_class($this), $suffix, __CLASS__); } public function Content() @@ -1226,7 +1222,8 @@ public function PreviewPanel() { $template = $this->getTemplatesWithSuffix('_PreviewPanel'); // Only render sections with preview panel - if ($template) { + $engine = $this->getTemplateEngine(); + if ($engine->hasTemplate($template)) { return $this->renderWith($template); } return null; @@ -1601,8 +1598,9 @@ public function Modals() public function Tools() { $templates = $this->getTemplatesWithSuffix('_Tools'); - if ($templates) { - $viewer = SSViewer::create($templates); + $engine = $this->getTemplateEngine(); + if ($engine->hasTemplate($templates)) { + $viewer = SSViewer::create($templates, $this->getTemplateEngine()); return $viewer->process($this); } else { return false; @@ -1623,8 +1621,9 @@ public function Tools() public function EditFormTools() { $templates = $this->getTemplatesWithSuffix('_EditFormTools'); - if ($templates) { - $viewer = SSViewer::create($templates); + $engine = $this->getTemplateEngine(); + if ($engine->hasTemplate($templates)) { + $viewer = SSViewer::create($templates, $this->getTemplateEngine()); return $viewer->process($this); } else { return false;