From 9d7ab10f290362e81f706e224ebef71cf9de9039 Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Thu, 7 Mar 2024 16:04:37 +0100 Subject: [PATCH] MDL-81163 course: Use component_callback for is_branded --- .../local/repository/content_item_readonly_repository.php | 6 ++---- course/externallib.php | 3 +-- course/format/classes/output/local/content/cm/cmicon.php | 4 ++-- theme/boost/classes/output/core_renderer.php | 3 +-- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/course/classes/local/repository/content_item_readonly_repository.php b/course/classes/local/repository/content_item_readonly_repository.php index 59995ec21ff..573860164df 100644 --- a/course/classes/local/repository/content_item_readonly_repository.php +++ b/course/classes/local/repository/content_item_readonly_repository.php @@ -132,8 +132,7 @@ class content_item_readonly_repository implements content_item_readonly_reposito $help = $this->get_core_module_help_string($mod->name); $archetype = plugin_supports('mod', $mod->name, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER); $purpose = plugin_supports('mod', $mod->name, FEATURE_MOD_PURPOSE, MOD_PURPOSE_OTHER); - $isbrandedfunction = $mod->name.'_is_branded'; - $isbranded = function_exists($isbrandedfunction) ? $isbrandedfunction() : false; + $isbranded = component_callback('mod_' . $mod->name, 'is_branded', [], false); $contentitem = new content_item( $mod->id, @@ -197,8 +196,7 @@ class content_item_readonly_repository implements content_item_readonly_reposito $help = $this->get_core_module_help_string($mod->name); $archetype = plugin_supports('mod', $mod->name, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER); $purpose = plugin_supports('mod', $mod->name, FEATURE_MOD_PURPOSE, MOD_PURPOSE_OTHER); - $isbrandedfunction = $mod->name.'_is_branded'; - $isbranded = function_exists($isbrandedfunction) ? $isbrandedfunction() : false; + $isbranded = component_callback('mod_' . $mod->name, 'is_branded', [], false); $icon = 'monologo'; // Quick check for monologo icons. diff --git a/course/externallib.php b/course/externallib.php index 2021386db3b..c815c52e766 100644 --- a/course/externallib.php +++ b/course/externallib.php @@ -258,8 +258,7 @@ class core_course_external extends external_api { $modcontext = context_module::instance($cm->id); - $isbrandedfunction = $cm->modname.'_is_branded'; - $isbranded = function_exists($isbrandedfunction) ? $isbrandedfunction() : false; + $isbranded = component_callback('mod_' . $cm->modname, 'is_branded', [], false); // Common info (for people being able to see the module or availability dates). $module['id'] = $cm->id; diff --git a/course/format/classes/output/local/content/cm/cmicon.php b/course/format/classes/output/local/content/cm/cmicon.php index c2d5bd13577..784b96eb1e6 100644 --- a/course/format/classes/output/local/content/cm/cmicon.php +++ b/course/format/classes/output/local/content/cm/cmicon.php @@ -78,8 +78,8 @@ class cmicon implements named_templatable, renderable { $iconurl = $mod->get_icon_url(); $iconclass = $iconurl->get_param('filtericon') ? '' : 'nofilter'; - $isbrandedfunction = $mod->modname.'_is_branded'; - $isbranded = function_exists($isbrandedfunction) ? $isbrandedfunction() : false; + $isbranded = component_callback('mod_' . $mod->modname, 'is_branded', [], false); + $data = [ 'uservisible' => $mod->uservisible, 'url' => $mod->url, diff --git a/theme/boost/classes/output/core_renderer.php b/theme/boost/classes/output/core_renderer.php index 203a42afec8..95cf185088c 100644 --- a/theme/boost/classes/output/core_renderer.php +++ b/theme/boost/classes/output/core_renderer.php @@ -170,8 +170,7 @@ class core_renderer extends \core_renderer { $purposeclass = plugin_supports('mod', $this->page->activityname, FEATURE_MOD_PURPOSE); $purposeclass .= ' activityiconcontainer icon-size-6'; $purposeclass .= ' modicon_' . $this->page->activityname; - $isbrandedfunction = $this->page->activityname.'_is_branded'; - $isbranded = function_exists($isbrandedfunction) ? $isbrandedfunction() : false; + $isbranded = component_callback('mod_' . $this->page->activityname, 'is_branded', [], false); $imagedata = html_writer::tag('div', $imagedata, ['class' => $purposeclass . ($isbranded ? ' isbranded' : '')]); if (!empty($USER->editing)) { $prefix = get_string('modulename', $this->page->activityname);