-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH Update code to reflect changes in template layer #1833
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -901,16 +901,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__); | ||
} | ||
Comment on lines
-904
to
910
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This used to give specific absolute file paths to templates. Thankfully, everywhere that used this doesn't actually need full absolute file paths. They just need some template candidates, and the ability to ask the configured engine if it can find files from those candidates or not. |
||
|
||
public function Content() | ||
|
@@ -927,7 +923,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; | ||
|
@@ -1286,7 +1283,7 @@ public function Modals() | |
/** | ||
* Renders a panel containing tools which apply to all displayed | ||
* "content" (mostly through {@link EditForm()}), for example a tree navigation or a filter panel. | ||
* Auto-detects applicable templates by naming convention: "<controller classname>_Tools.ss", | ||
* Auto-detects applicable templates by naming convention: "<controller classname>_Tools", | ||
* and takes the most specific template (see {@link getTemplatesWithSuffix()}). | ||
* To explicitly disable the panel in the subclass, simply create a more specific, empty template. | ||
* | ||
|
@@ -1295,8 +1292,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; | ||
|
@@ -1317,8 +1315,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; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gives the exact same result. There was no need for the
chooseTemplate()
there inbetween (which is good 'cause we can't do that anymore)