From 79ebac4a6cd8b76324621d01e2dd555f3c6b53cf Mon Sep 17 00:00:00 2001 From: Joe Parsons <471936+joeparsons@users.noreply.github.com> Date: Tue, 15 Oct 2024 16:56:39 -0700 Subject: [PATCH] Closes #3770: Add menu links to the /admin/config/az-quickstart page --- modules/custom/az_core/az_core.links.menu.yml | 20 +++++++- .../custom/az_google_tag/az_google_tag.module | 48 +++++++++++++------ 2 files changed, 52 insertions(+), 16 deletions(-) diff --git a/modules/custom/az_core/az_core.links.menu.yml b/modules/custom/az_core/az_core.links.menu.yml index 1257466c51..3a3d1dd66e 100644 --- a/modules/custom/az_core/az_core.links.menu.yml +++ b/modules/custom/az_core/az_core.links.menu.yml @@ -2,10 +2,28 @@ az_core.az_quickstart: route_name: az_core.az_quickstart parent: system.admin_config title: 'Arizona Quickstart' - description: 'Settings provided by Arizona Quickstart modules.' + description: 'Settings provided by Arizona Quickstart modules' az_core.az_settings: route_name: az_core.az_settings parent: az_core.az_quickstart title: 'Arizona Quickstart Settings' description: 'Settings provided by Quickstart Core and various other Arizona Quickstart modules.' + +az_core.az_docs: + url: https://quickstart.arizona.edu + parent: az_core.az_quickstart + title: 'Documentation' + description: 'Arizona Quickstart 2 Documentation' + options: + attributes: + target: '_blank' + +az_core.az_releases: + url: https://github.com/az-digital/az_quickstart/releases + parent: az_core.az_quickstart + title: 'Releases' + description: 'Arizona Quickstart 2 Releases' + options: + attributes: + target: '_blank' diff --git a/modules/custom/az_google_tag/az_google_tag.module b/modules/custom/az_google_tag/az_google_tag.module index 20d649cd26..89683c9895 100644 --- a/modules/custom/az_google_tag/az_google_tag.module +++ b/modules/custom/az_google_tag/az_google_tag.module @@ -11,24 +11,42 @@ use Drupal\Core\Url; * Implements hook_toolbar_alter(). */ function az_google_tag_toolbar_alter(&$items) { - if (\Drupal::service('module_handler')->moduleExists('az_core')) { - $site_url = \Drupal::request()->getHost(); - $items['az_quickstart']['tray']['az_links']['#links']['analytics'] = [ - 'title' => t('Analytics Dashboard'), - 'url' => Url::fromUri('https://lookerstudio.google.com/reporting/ef02c272-afe4-4862-b4bd-8706e3436b2f/page/nbaTD', [ - 'query' => [ - 'params' => '{"df21":"include%EE%80%800%EE%80%80IN%EE%80%80' . $site_url . '"}', - ], - 'absolute' => TRUE, - ]), - 'attributes' => [ - 'title' => t('Site Analytics Dashboard'), - 'target' => t('_blank'), - ], - ]; + if (\Drupal::service('module_handler')->moduleExists('az_core')) { + $items['az_quickstart']['tray']['az_links']['#links']['analytics'] = _az_google_tag_analytics_dashboard_link_info(); + } +} + +/** + * Implements hook_menu_links_discovered_alter(). + */ +function az_google_tag_menu_links_discovered_alter(&$links) { + if (\Drupal::service('module_handler')->moduleExists('az_core')) { + $links['az_google_tag.analytics_dashboard'] = _az_google_tag_analytics_dashboard_link_info(); + $links['az_google_tag.analytics_dashboard']['parent'] = 'az_core.az_quickstart'; + $links['az_google_tag.analytics_dashboard']['description'] = t('Site Analytics Dashboard'); } } +/** + * Returns analytics dashboard link info common to various render elements. + */ +function _az_google_tag_analytics_dashboard_link_info() { + $site_url = \Drupal::request()->getHost(); + return [ + 'title' => t('Analytics Dashboard'), + 'url' => Url::fromUri('https://lookerstudio.google.com/reporting/ef02c272-afe4-4862-b4bd-8706e3436b2f/page/nbaTD', [ + 'query' => [ + 'params' => '{"df21":"include%EE%80%800%EE%80%80IN%EE%80%80' . $site_url . '"}', + ], + 'absolute' => TRUE, + ]), + 'attributes' => [ + 'title' => t('Site Analytics Dashboard'), + 'target' => t('_blank'), + ], + ]; +} + /** * Checks if the consent mode config setting is enabled for any Google Tags. *