diff --git a/modules/social_features/social_group/social_group.services.yml b/modules/social_features/social_group/social_group.services.yml index 0ca9ae3d058..af65a4fabcf 100644 --- a/modules/social_features/social_group/social_group.services.yml +++ b/modules/social_features/social_group/social_group.services.yml @@ -45,7 +45,7 @@ services: - {name: config.factory.override, priority: 10} social_group.group_statistics: class: Drupal\social_group\GroupStatistics - arguments: ['@database', '@entity_type.manager'] + arguments: ['@database'] social_group.group_mute_notify: class: Drupal\social_group\GroupMuteNotify arguments: ['@flag', '@entity_type.manager'] diff --git a/modules/social_features/social_group/src/GroupStatistics.php b/modules/social_features/social_group/src/GroupStatistics.php index 746a7a9139f..69e1d704f80 100644 --- a/modules/social_features/social_group/src/GroupStatistics.php +++ b/modules/social_features/social_group/src/GroupStatistics.php @@ -20,24 +20,14 @@ class GroupStatistics { */ protected $database; - /** - * The entity type manager interface. - * - * @var \Drupal\Core\Entity\EntityTypeManagerInterface - */ - protected $entityTypeManager; - /** * Constructor for SocialGroupMembersCount. * * @param \Drupal\Core\Database\Connection $connection * The database connection. - * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager - * The entity type manager interface. */ - public function __construct(Connection $connection, EntityTypeManagerInterface $entity_type_manager) { + public function __construct(Connection $connection) { $this->database = $connection; - $this->entityTypeManager = $entity_type_manager; } /** @@ -65,7 +55,7 @@ public function getGroupMemberCount(GroupInterface $group) { * The number of nodes. */ public function getGroupNodeCount(GroupInterface $group, $type) { - return $this->count($group, 'group_node:' . $type); + return $this->count($group, 'group_node-' . $type); } /** @@ -81,12 +71,12 @@ public function getGroupNodeCount(GroupInterface $group, $type) { */ protected function count(GroupInterface $group, $type) { // Additional caching not required since views does this for us. - return $this->entityTypeManager->getStorage('group_content')->getQuery() - ->accessCheck(FALSE) - ->condition('gid', $group->id()) - ->condition('plugin_id', $type) - ->count() - ->execute(); + $query = $this->database->select('group_relationship_field_data', 'gcfd'); + $query->addField('gcfd', 'gid'); + $query->condition('gcfd.gid', $group->id()); + $query->condition('gcfd.type', $group->getGroupType()->id() . '-' . $type, 'LIKE'); + + return $query->countQuery()->execute()->fetchField(); } }