Skip to content

Commit

Permalink
MDL-81047 core: Rename standard_head_html_prepend hook
Browse files Browse the repository at this point in the history
This commit updates the name of the standard_head_html_prepend hook to
meet coding style agreed in MDL-79077.
  • Loading branch information
andrewnicols committed Mar 8, 2024
1 parent 38a3310 commit 0a30867
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 15 deletions.
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace tool_mobile\local\hooks\output;
namespace tool_mobile\local\hook\output;

/**
* Allows plugins to add any elements to the page <head> html tag
Expand All @@ -23,14 +23,13 @@
* @copyright 2023 Marina Glancy
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class standard_head_html_prepend {

class before_standard_head_html_generation {
/**
* Callback to add head elements.
*
* @param \core\hook\output\standard_head_html_prepend $hook
* @param \core\hook\output\before_standard_head_html_generation $hook
*/
public static function callback(\core\hook\output\standard_head_html_prepend $hook): void {
public static function callback(\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)) {
Expand All @@ -45,7 +44,7 @@ public static function callback(\core\hook\output\standard_head_html_prepend $ho

if (!empty($mobilesettings->androidappid)) {
$mobilemanifesturl = "$CFG->wwwroot/$CFG->admin/tool/mobile/mobile.webmanifest.php";
$hook->add_html('<link rel="manifest" href="'.$mobilemanifesturl.'" />');
$hook->add_html('<link rel="manifest" href="' . $mobilemanifesturl . '" />');
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions admin/tool/mobile/db/hooks.php
Expand Up @@ -26,8 +26,8 @@

$callbacks = [
[
'hook' => core\hook\output\standard_head_html_prepend::class,
'callback' => 'tool_mobile\local\hooks\output\standard_head_html_prepend::callback',
'hook' => core\hook\output\before_standard_head_html_generation::class,
'callback' => 'tool_mobile\local\hook\output\before_standard_head_html_generation::callback',
'priority' => 0,
],
];
2 changes: 1 addition & 1 deletion admin/tool/mobile/version.php
Expand Up @@ -23,7 +23,7 @@
*/

defined('MOODLE_INTERNAL') || die();
$plugin->version = 2023100900; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2024022600; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2023100400; // Requires this Moodle version.
$plugin->component = 'tool_mobile'; // Full name of the plugin (used for diagnostics).
$plugin->dependencies = [
Expand Down
Expand Up @@ -26,7 +26,7 @@
#[\core\attribute\tags('output')]
#[\core\attribute\label('Allows plugins to add any elements to the page &lt;head&gt; html tag.')]
#[\core\attribute\hook\replaces_callbacks('before_standard_html_head')]
class standard_head_html_prepend {
class before_standard_head_html_generation {
/** @var string $output Stores results from callbacks */
private $output = '';

Expand Down
6 changes: 2 additions & 4 deletions lib/outputrenderers.php
Expand Up @@ -698,15 +698,13 @@ public function standard_head_html() {
$this->page->blocks->ensure_content_created($region, $this);
}

$output = '';

// Give plugins an opportunity to add any head elements. The callback
// must always return a string containing valid html head content.

$hook = new \core\hook\output\standard_head_html_prepend();
$hook = new \core\hook\output\before_standard_head_html_generation();
\core\hook\manager::get_instance()->dispatch($hook);
$hook->process_legacy_callbacks();
$output .= $hook->get_output();
$output = $hook->get_output();

// Allow a url_rewrite plugin to setup any dynamic head content.
if (isset($CFG->urlrewriteclass) && !isset($CFG->upgraderunning)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/upgrade.txt
Expand Up @@ -37,7 +37,7 @@ information provided here is intended especially for developers.
- get_attempts_available(): Used to get the number of attempts available for the task.
* There is a new DML method $DB->get_fieldset. For some reason, this did not exist even though get_fieldset_select etc. did.
* The following callbacks have been migrated to hooks:
- before_standard_html_head() -> core\hook\output\standard_head_html_prepend
- before_standard_html_head() -> core\hook\output\before_standard_head_html_generation
* Deprecated PARAM_ types with the exception of PARAM_CLEAN now emit a deprecation exception. These were all deprecated in Moodle 2.0.
* A new \core\deprecated attribute can be used to more clearly describe deprecated methods.
* A new \core\deprecation class can be used to inspect for deprecated attributes:
Expand Down

0 comments on commit 0a30867

Please sign in to comment.