public function GroupStatisticBlock::build in Open Social 8.8
Same name and namespace in other branches
- 8.9 modules/social_features/social_group/src/Plugin/Block/GroupStatisticBlock.php \Drupal\social_group\Plugin\Block\GroupStatisticBlock::build()
 - 10.3.x modules/social_features/social_group/src/Plugin/Block/GroupStatisticBlock.php \Drupal\social_group\Plugin\Block\GroupStatisticBlock::build()
 - 10.0.x modules/social_features/social_group/src/Plugin/Block/GroupStatisticBlock.php \Drupal\social_group\Plugin\Block\GroupStatisticBlock::build()
 - 10.1.x modules/social_features/social_group/src/Plugin/Block/GroupStatisticBlock.php \Drupal\social_group\Plugin\Block\GroupStatisticBlock::build()
 - 10.2.x modules/social_features/social_group/src/Plugin/Block/GroupStatisticBlock.php \Drupal\social_group\Plugin\Block\GroupStatisticBlock::build()
 
Builds and returns the renderable array for this block plugin.
If a block should not be rendered because it has no content, then this method must also ensure to return no content: it must then only return an empty array, or an empty array with #cache set (with cacheability metadata indicating the circumstances for it being empty).
Return value
array A renderable array representing the content of the block.
Overrides BlockPluginInterface::build
See also
\Drupal\block\BlockViewBuilder
File
- modules/
social_features/ social_group/ src/ Plugin/ Block/ GroupStatisticBlock.php, line 78  
Class
- GroupStatisticBlock
 - Provides a 'GroupStatisticBlock' block.
 
Namespace
Drupal\social_group\Plugin\BlockCode
public function build() {
  $build = [];
  $group = _social_group_get_current_group();
  if (!empty($group)) {
    // Content.
    $content = $this->entityTypeManager
      ->getViewBuilder('group')
      ->view($group, 'statistic');
    $build['content'] = $content;
    // Cache tags.
    $build['#cache']['tags'][] = 'group_block:' . $group
      ->id();
  }
  // Cache contexts.
  return $build;
}