public function SocialGroupMembershipCount::render in Open Social 10.0.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/src/Plugin/views/field/SocialGroupMembershipCount.php \Drupal\social_group\Plugin\views\field\SocialGroupMembershipCount::render()
- 10.3.x modules/social_features/social_group/src/Plugin/views/field/SocialGroupMembershipCount.php \Drupal\social_group\Plugin\views\field\SocialGroupMembershipCount::render()
- 10.1.x modules/social_features/social_group/src/Plugin/views/field/SocialGroupMembershipCount.php \Drupal\social_group\Plugin\views\field\SocialGroupMembershipCount::render()
- 10.2.x modules/social_features/social_group/src/Plugin/views/field/SocialGroupMembershipCount.php \Drupal\social_group\Plugin\views\field\SocialGroupMembershipCount::render()
Renders the field.
Parameters
\Drupal\views\ResultRow $values: The values retrieved from a single row of a view's query result.
Return value
string|\Drupal\Component\Render\MarkupInterface The rendered output. If the output is safe it will be wrapped in an object that implements MarkupInterface. If it is empty or unsafe it will be a string.
Overrides FieldPluginBase::render
File
- modules/
social_features/ social_group/ src/ Plugin/ views/ field/ SocialGroupMembershipCount.php, line 27
Class
- SocialGroupMembershipCount
- Field handler to present the groups membership count.
Namespace
Drupal\social_group\Plugin\views\fieldCode
public function render(ResultRow $row) {
$group_content = $this
->getEntity($row);
// Grab the group from the group_invite.
if ($group_content instanceof GroupContent) {
$group = $group_content
->getGroup();
if ($group instanceof Group) {
/** @var \Drupal\social_group\GroupStatistics $group_statistics */
$group_statistics = \Drupal::service('social_group.group_statistics');
// Return the group member count.
return $group_statistics
->getGroupMemberCount($group);
}
}
}