From ef596b312762a2e60379933e1017bd90be52f175 Mon Sep 17 00:00:00 2001 From: Roman Chekhaniuk Date: Mon, 16 Sep 2024 15:02:55 +0300 Subject: [PATCH] Issue #3474659: Fix filters for "All groups" view. --- .../social_tagging/social_tagging.module | 22 ++++++++++++++++++- .../src/Form/SocialTaggingSettingsForm.php | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/modules/social_features/social_tagging/social_tagging.module b/modules/social_features/social_tagging/social_tagging.module index 0f9082bd361..121ef870c1c 100644 --- a/modules/social_features/social_tagging/social_tagging.module +++ b/modules/social_features/social_tagging/social_tagging.module @@ -530,7 +530,7 @@ function social_tagging_form_views_exposed_form_alter(&$form, FormStateInterface 'views-exposed-form-group-topics-page-group-topics' => ['node_topic'], 'views-exposed-form-group-events-page-group-events' => ['node_event'], 'views-exposed-form-group-books-page-group-books' => ['node_topic'], - 'views-exposed-form-newest-groups-page-all-groups' => ['group'], + 'views-exposed-form-newest-groups-page-all-groups' => _social_tagging_get_group_placement_ids(), 'views-exposed-form-newest-users-page-newest-users' => ['profile'], ]; $form_ids = array_keys($keys); @@ -741,3 +741,23 @@ function _social_tagging_field(): FieldStorageDefinitionInterface { ->setDisplayConfigurable('form', TRUE) ->setDisplayConfigurable('view', TRUE); } + +/** + * Get array of available "Placement ID" for groups. + * + * @return array + * The array of available "Placement ID" for groups. + */ +function _social_tagging_get_group_placement_ids(): array { + $group_bundles = \Drupal::service('entity_type.bundle.info')->getBundleInfo('group'); + + if (!$group_bundles) { + return []; + } + + $group_bundles = array_keys($group_bundles); + + return array_map(function ($group_bundle) { + return 'group_' . $group_bundle; + }, $group_bundles); +} diff --git a/modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php b/modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php index fecc47b4ddd..8e99749ade2 100644 --- a/modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php +++ b/modules/social_features/social_tagging/src/Form/SocialTaggingSettingsForm.php @@ -198,7 +198,7 @@ public function buildForm(array $form, FormStateInterface $form_state) { $form['node_type_settings'][$key] = [ '#type' => 'checkbox', '#title' => $title, - '#default_value' => $config->get($key) ?: !empty($bundles), + '#default_value' => $config->get($key), ]; } }