MDL-80746 core: make comboboxsearch a named_templatable
This class was rolling its own version of get_template_name, which meant that calling code needed to first call get_template and was forced to use render_from_template(). This fixes that by implementing the named_templatable interface and the get_template_name method. Now, renderables that extend comboboxsearch can just be passed to render() for rendering.
This commit is contained in:
committed by
Mihail Geshoski
parent
f80045bb10
commit
0504fd353b
+5
-5
@@ -47,13 +47,13 @@ class core_grades_renderer extends plugin_renderer_base {
|
||||
* @param object $course The course object.
|
||||
* @param string|null $groupactionbaseurl This parameter has been deprecated since 4.4 and should not be used anymore.
|
||||
* @return string|null The raw HTML to render.
|
||||
* @deprecated since 4.5. Use \core_course\output\actionbar\renderer' instead.
|
||||
* @deprecated since 4.5. See replacement renderable \core_course\output\actionbar\group_selector instead.
|
||||
* @todo Final deprecation in Moodle 6.0. See MDL-82116.
|
||||
*/
|
||||
#[\core\attribute\deprecated(
|
||||
replacement: null,
|
||||
since: '4.5',
|
||||
reason: 'Moved to \core_course\output\actionbar\renderer.'
|
||||
reason: 'See replacement renderable \core_course\output\actionbar\group_selector.'
|
||||
)]
|
||||
public function group_selector(object $course, ?string $groupactionbaseurl = null): ?string {
|
||||
global $USER;
|
||||
@@ -112,7 +112,7 @@ class core_grades_renderer extends plugin_renderer_base {
|
||||
'group',
|
||||
$activegroup
|
||||
);
|
||||
return $this->render_from_template($groupdropdown->get_template(), $groupdropdown->export_for_template($this));
|
||||
return $this->render($groupdropdown);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,13 +124,13 @@ class core_grades_renderer extends plugin_renderer_base {
|
||||
* @param context $context Our current context.
|
||||
* @param string $slug The slug for the report that called this function.
|
||||
* @return stdClass The data to output.
|
||||
* @deprecated since 4.5. Use \core_course\output\actionbar\renderer' instead.
|
||||
* @deprecated since 4.5. See replacement renderable \core_course\output\actionbar\initials_selector instead.
|
||||
* @todo Final deprecation in Moodle 6.0. See MDL-82421.
|
||||
*/
|
||||
#[\core\attribute\deprecated(
|
||||
replacement: null,
|
||||
since: '4.5',
|
||||
reason: 'Moved to \core_course\output\actionbar\renderer.'
|
||||
reason: 'See replacement renderable \core_course\output\actionbar\initials_selector.'
|
||||
)]
|
||||
public function initials_selector(
|
||||
object $course,
|
||||
|
||||
@@ -107,7 +107,7 @@ class gradereport_singleview_renderer extends plugin_renderer_base {
|
||||
'itemid',
|
||||
$gradeitemid
|
||||
);
|
||||
return $this->render_from_template($dropdown->get_template(), $dropdown->export_for_template($this));
|
||||
return $this->render($dropdown);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,7 +25,7 @@ use core\exception\moodle_exception;
|
||||
* @copyright 2022 Mathew May <Mathew.solutions>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class comboboxsearch implements renderable, templatable {
|
||||
class comboboxsearch implements renderable, named_templatable {
|
||||
/** @var bool $renderlater Should the dropdown render straightaway? We sometimes need to output the component without all of the
|
||||
* data and leave the rendering of any defaults and actual data to the caller. We will give you a basic placeholder that can
|
||||
* then be easily replaced.*/
|
||||
@@ -154,9 +154,16 @@ class comboboxsearch implements renderable, templatable {
|
||||
/**
|
||||
* Returns the standard template for the dropdown.
|
||||
*
|
||||
* @deprecated since Moodle 4.5. {@see named_templatable::get_template_name() instead}
|
||||
* @return string
|
||||
*/
|
||||
public function get_template(): string {
|
||||
debugging('get_template is deprecated. Please use get_template_name instead');
|
||||
|
||||
return 'core/comboboxsearch';
|
||||
}
|
||||
|
||||
public function get_template_name(renderer_base $renderer): string {
|
||||
return 'core/comboboxsearch';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user