Skip to content

Commit

Permalink
ENH Update code to reflect changes in template layer
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli committed Oct 13, 2024
1 parent ed8ee37 commit e70be94
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
3 changes: 1 addition & 2 deletions code/Forms/GridFieldDetailFormPreviewExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
23 changes: 11 additions & 12 deletions code/LeftAndMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit e70be94

Please sign in to comment.