From 070bf1ed8e67d73ed3970211a101036ae1a55ee9 Mon Sep 17 00:00:00 2001 From: Andy Footner Date: Tue, 7 Oct 2025 13:56:46 +0200 Subject: [PATCH] Merge pull request #904 from lazysoundsystem/895-change-hook Use the appropriate hook --- localgov.profile | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/localgov.profile b/localgov.profile index af6aafa..4511c9d 100644 --- a/localgov.profile +++ b/localgov.profile @@ -6,17 +6,19 @@ */ /** - * Implements hook_page_attachments(). + * Implements hook_page_attachments_alter(). + * + * Use LocalGov Drupal for site generator metatag. */ -function localgov_page_attachments(array &$attachments): void { +function localgov_page_attachments_alter(array &$attachments): void { foreach ($attachments['#attached']['html_head'] as &$html_head) { - $name = $html_head[1]; - $core_version = \Drupal::VERSION; - $parts = explode('.', $core_version); + if ($html_head[1] == 'system_meta_generator') { + $parts = explode('.', \Drupal::VERSION); - if ($name == 'system_meta_generator') { $tag = &$html_head[0]; $tag['#attributes']['content'] = 'Drupal ' . $parts[0] . ' (LocalGov Drupal | https://localgovdrupal.org)'; + + break; } } }