From 66dcf063d406fe18d340c163202818904937e52b Mon Sep 17 00:00:00 2001 From: Maarten Segers Date: Thu, 2 May 2019 15:49:27 +0200 Subject: [PATCH 1/7] Update og.module --- og.module | 1 + 1 file changed, 1 insertion(+) diff --git a/og.module b/og.module index 695e7d1d5..cd93ecec3 100755 --- a/og.module +++ b/og.module @@ -326,6 +326,7 @@ function og_theme($existing, $type, $theme, $path) { * @param array $variables * An associative array containing: * - count: An integer representing the number of members in the group. + * - membership_states: The membership states that are taken into account. * - group: The group, which is a content entity. */ function template_preprocess_og_member_count(array &$variables) { From ea1b8ab1f9b237732626aa6f6876f07f27940bce Mon Sep 17 00:00:00 2001 From: Maarten Segers Date: Thu, 2 May 2019 15:53:16 +0200 Subject: [PATCH 2/7] Added group label to block build --- src/Plugin/Block/MemberCountBlock.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Plugin/Block/MemberCountBlock.php b/src/Plugin/Block/MemberCountBlock.php index 993b93652..0b8b7e674 100644 --- a/src/Plugin/Block/MemberCountBlock.php +++ b/src/Plugin/Block/MemberCountBlock.php @@ -138,6 +138,7 @@ public function build() { '#theme' => 'og_member_count', '#count' => count($membership_ids), '#group' => $group, + '#group_label' => $group->label(), '#membership_states' => $states, ]; } From 74ac9a518ea6bc90a5b2e197a46bad4f40297ef2 Mon Sep 17 00:00:00 2001 From: Maarten Segers Date: Thu, 2 May 2019 15:54:06 +0200 Subject: [PATCH 3/7] Added parent::defaultConfiguration() --- src/Plugin/Block/MemberCountBlock.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugin/Block/MemberCountBlock.php b/src/Plugin/Block/MemberCountBlock.php index 0b8b7e674..d0f776743 100644 --- a/src/Plugin/Block/MemberCountBlock.php +++ b/src/Plugin/Block/MemberCountBlock.php @@ -81,7 +81,7 @@ public function defaultConfiguration() { return [ 'count_blocked_users' => FALSE, 'count_pending_users' => FALSE, - ]; + ] + parent::defaultConfiguration(); } /** From 3e9a5806c4d27fafabef4f9958bf6afd74dfc10e Mon Sep 17 00:00:00 2001 From: Maarten Segers Date: Thu, 2 May 2019 15:55:10 +0200 Subject: [PATCH 4/7] Update og-member-count.html.twig --- templates/og-member-count.html.twig | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/og-member-count.html.twig b/templates/og-member-count.html.twig index 6ad68425c..b1bff65e0 100644 --- a/templates/og-member-count.html.twig +++ b/templates/og-member-count.html.twig @@ -6,6 +6,7 @@ * Available variables: * - count: The number of members in the group. * - membership_states: An array of membership states included in the count. + * - group: The group, which is a content entity. * - group_label: The group label. * * @see \Drupal\og\Plugin\Block\MemberCountBlock From f5f062cfe922ac21482934dad9b9ed25d74fd1b4 Mon Sep 17 00:00:00 2001 From: Maarten Segers Date: Thu, 2 May 2019 15:56:42 +0200 Subject: [PATCH 5/7] Update MemberCountBlockTest.php --- tests/src/Kernel/Plugin/Block/MemberCountBlockTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/src/Kernel/Plugin/Block/MemberCountBlockTest.php b/tests/src/Kernel/Plugin/Block/MemberCountBlockTest.php index 649233990..48b3691b2 100644 --- a/tests/src/Kernel/Plugin/Block/MemberCountBlockTest.php +++ b/tests/src/Kernel/Plugin/Block/MemberCountBlockTest.php @@ -273,7 +273,7 @@ protected function renderBlock($group_key) { */ protected function assertMemberCount($group_key, $expected_count) { $expected_string = (string) $this->formatPlural($expected_count, '@label has 1 member.', '@label has @count members', ['@label' => $this->groups[$group_key]->label()]); - $this->assertTrue(strpos($this->renderBlock($group_key), $expected_string) !== FALSE); + $this->assertContains($expected_string, (string) $this->renderBlock($group_key)); } /** From f60b8d85fb282add984afd0a0016426cac97ae1f Mon Sep 17 00:00:00 2001 From: Maarten Segers Date: Thu, 2 May 2019 17:55:59 +0200 Subject: [PATCH 6/7] Update og.module --- og.module | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/og.module b/og.module index cd93ecec3..5c8726317 100755 --- a/og.module +++ b/og.module @@ -318,24 +318,6 @@ function og_theme($existing, $type, $theme, $path) { ]; } -/** - * Prepares variables for member count templates. - * - * Default template: og-member-count.html.twig. - * - * @param array $variables - * An associative array containing: - * - count: An integer representing the number of members in the group. - * - membership_states: The membership states that are taken into account. - * - group: The group, which is a content entity. - */ -function template_preprocess_og_member_count(array &$variables) { - /** @var \Drupal\Core\Entity\ContentEntityInterface $group */ - $group = $variables['group']; - - $variables['group_label'] = $group->label(); -} - /** * Invalidates group content cache tags for the groups this entity belongs to. * From 0b2a20cc771ebe620acb6779736b398e67c5ada9 Mon Sep 17 00:00:00 2001 From: Maarten Segers Date: Thu, 2 May 2019 17:57:53 +0200 Subject: [PATCH 7/7] Update og.module --- og.module | 1 + 1 file changed, 1 insertion(+) diff --git a/og.module b/og.module index 5c8726317..5f0953a57 100755 --- a/og.module +++ b/og.module @@ -313,6 +313,7 @@ function og_theme($existing, $type, $theme, $path) { 'count' => 0, 'membership_states' => [], 'group' => NULL, + 'group_label' => NULL, ], ], ];