diff --git a/.github/workflows/localgov_microsites.yml b/.github/workflows/localgov_microsites.yml index beb2463..e9abd2e 100644 --- a/.github/workflows/localgov_microsites.yml +++ b/.github/workflows/localgov_microsites.yml @@ -21,15 +21,13 @@ jobs: strategy: fail-fast: false matrix: - include: - - profile-version: '2.1.x' - project-version: '2.x' - drupal-version: '~9.4' - php-version: '8.1' - - profile-version: '3.x' - project-version: '3.x' - drupal-version: '~10.0' - php-version: '8.1' + profile-version: + - '4.x' + drupal-version: + - '~10.0' + php-version: + - '8.1' + - '8.2' steps: @@ -107,15 +105,13 @@ jobs: strategy: fail-fast: false matrix: - include: - - profile-version: '2.1.x' - project-version: '2.x' - drupal-version: '~9.4' - php-version: '8.1' - - profile-version: '3.x' - project-version: '3.x' - drupal-version: '~10.0' - php-version: '8.1' + profile-version: + - '4.x' + drupal-version: + - '~10.0' + php-version: + - '8.1' + - '8.2' steps: @@ -145,15 +141,13 @@ jobs: strategy: fail-fast: false matrix: - include: - - profile-version: '2.1.x' - project-version: '2.x' - drupal-version: '~9.4' - php-version: '8.1' - - profile-version: '3.x' - project-version: '3.x' - drupal-version: '~10.0' - php-version: '8.1' + profile-version: + - '4.x' + drupal-version: + - '~10.0' + php-version: + - '8.1' + - '8.2' steps: @@ -182,15 +176,13 @@ jobs: strategy: fail-fast: false matrix: - include: - - profile-version: '2.1.x' - project-version: '2.x' - drupal-version: '~9.4' - php-version: '8.1' - - profile-version: '3.x' - project-version: '3.x' - drupal-version: '~10.0' - php-version: '8.1' + profile-version: + - '4.x' + drupal-version: + - '~10.0' + php-version: + - '8.1' + - '8.2' steps: diff --git a/composer.json b/composer.json index 90c12a8..eb10b7a 100644 --- a/composer.json +++ b/composer.json @@ -7,6 +7,6 @@ "require": { "drupal/twig_tweak": "^3.2", "localgovdrupal/localgov_base": "^1.0.0", - "localgovdrupal/localgov_microsites_group": "^2.0.0@beta || ^3.0.0@alpha || ^4.0.0@alpha " + "localgovdrupal/localgov_microsites_group": "^4.0.0-alpha3" } } diff --git a/localgov_microsites_base.theme b/localgov_microsites_base.theme index 2981923..f638443 100644 --- a/localgov_microsites_base.theme +++ b/localgov_microsites_base.theme @@ -13,18 +13,13 @@ use Drupal\views\ViewExecutable; */ function localgov_microsites_base_preprocess_html(&$variables) { - $parent_group_id = \Drupal::service('domain_group_resolver')->getActiveDomainGroupId(); - if ($parent_group_id) { - $group = \Drupal::entityTypeManager()->getStorage('group')->load($parent_group_id); - } - if (empty($group)) { - $group = \Drupal::request()->attributes->get('group'); - } + // Load the group by context. See localgov_microsites_group.module. + $group = localgov_microsites_group_get_by_context(); if ($group instanceof MicrositeGroupInterface) { // Adds classes that can be used to let CSS target specific microsites. $variables['attributes']['class'][] = 'lgd-ms'; - $variables['attributes']['class'][] = 'lgd-ms--' . $parent_group_id; + $variables['attributes']['class'][] = 'lgd-ms--' . $group->id(); // Styleguide primary colour. if (!is_null($group->get('lgms_primary_colour')[0])) { @@ -444,16 +439,11 @@ function localgov_microsites_base_preprocess_node(&$variables) { $variables['content_type'] = $variables['node']->getType(); $variables['teaser'] = $variables['view_mode'] == 'teaser'; - $parent_group_id = \Drupal::service('domain_group_resolver')->getActiveDomainGroupId(); - if ($parent_group_id) { - $group = \Drupal::entityTypeManager()->getStorage('group')->load($parent_group_id); - } - if (empty($group)) { - $group = \Drupal::request()->attributes->get('group'); - } + // Load the group by context. See localgov_microsites_group.module. + $group = localgov_microsites_group_get_by_context(); if ($group instanceof MicrositeGroupInterface) { - $front_page = \Drupal::config('domain.config.group_' . $parent_group_id . '.system.site')->get('page.front'); + $front_page = \Drupal::config('domain.config.group_' . $group->id() . '.system.site')->get('page.front'); $current_path = \Drupal::service('path.current')->getPath(); $current_path_alias = \Drupal::service('path_alias.manager')->getAliasByPath($current_path); @@ -527,13 +517,8 @@ function localgov_microsites_base_views_pre_render(ViewExecutable $view) { $view->element['#attached']['library'][] = 'localgov_microsites_base/view-events'; - $parent_group_id = \Drupal::service('domain_group_resolver')->getActiveDomainGroupId(); - if ($parent_group_id) { - $group = \Drupal::entityTypeManager()->getStorage('group')->load($parent_group_id); - } - else { - $group = \Drupal::request()->attributes->get('group'); - } + // Load the group by context. See localgov_microsites_group.module. + $group = localgov_microsites_group_get_by_context(); if (!is_null($group) && !empty($group->get('lgms_teaser_image_style')->getValue())) { @@ -576,13 +561,8 @@ function localgov_microsites_base_preprocess_page(&$variables) { $variables['site_name'] = $config->get('name'); $variables['site_slogan'] = $config->get('slogan'); - $parent_group_id = \Drupal::service('domain_group_resolver')->getActiveDomainGroupId(); - if ($parent_group_id) { - $group = \Drupal::entityTypeManager()->getStorage('group')->load($parent_group_id); - } - if (empty($group)) { - $group = \Drupal::request()->attributes->get('group'); - } + // Load the group by context. See localgov_microsites_group.module. + $group = localgov_microsites_group_get_by_context(); if ($group instanceof MicrositeGroupInterface) {