Skip to content

Commit

Permalink
MDL-81144 tool_mobile: Standarise hook locations
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Apr 2, 2024
1 parent e3f2b03 commit 6ad9f26
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 54 deletions.
28 changes: 28 additions & 0 deletions admin/tool/mobile/classes/hook_callbacks.php
Expand Up @@ -26,6 +26,34 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class hook_callbacks {
/**
* Callback to add head elements.
*
* @param \core\hook\output\before_standard_head_html_generation $hook
*/
public static function before_standard_head_html_generation(
\core\hook\output\before_standard_head_html_generation $hook,
): void {
global $CFG, $PAGE;
// Smart App Banners meta tag is only displayed if mobile services are enabled and configured.
if (!empty($CFG->enablemobilewebservice)) {
$mobilesettings = get_config('tool_mobile');
if (!empty($mobilesettings->enablesmartappbanners)) {
if (!empty($mobilesettings->iosappid)) {
$hook->add_html(
'<meta name="apple-itunes-app" content="app-id=' . s($mobilesettings->iosappid) . ', ' .
'app-argument=' . $PAGE->url->out() . '"/>'
);
}

if (!empty($mobilesettings->androidappid)) {
$mobilemanifesturl = "$CFG->wwwroot/$CFG->admin/tool/mobile/mobile.webmanifest.php";
$hook->add_html('<link rel="manifest" href="' . $mobilemanifesturl . '" />');
}
}
}
}

/**
* Callback to add head elements.
*
Expand Down

This file was deleted.

3 changes: 1 addition & 2 deletions admin/tool/mobile/db/hooks.php
Expand Up @@ -27,8 +27,7 @@
$callbacks = [
[
'hook' => \core\hook\output\before_standard_head_html_generation::class,
'callback' => [\tool_mobile\local\hook\output\before_standard_head_html_generation::class, 'callback'],
'priority' => 0,
'callback' => [\tool_mobile\hook_callbacks::class, 'before_standard_head_html_generation'],
],
[
'hook' => \core\hook\output\before_standard_footer_html_generation::class,
Expand Down

0 comments on commit 6ad9f26

Please sign in to comment.