You are here

function _social_group_get_current_group in Open Social 8

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_group/social_group.module \_social_group_get_current_group()
  2. 8.2 modules/social_features/social_group/social_group.module \_social_group_get_current_group()
  3. 8.3 modules/social_features/social_group/social_group.module \_social_group_get_current_group()
  4. 8.4 modules/social_features/social_group/social_group.module \_social_group_get_current_group()
  5. 8.5 modules/social_features/social_group/social_group.module \_social_group_get_current_group()
  6. 8.6 modules/social_features/social_group/social_group.module \_social_group_get_current_group()
  7. 8.7 modules/social_features/social_group/social_group.module \_social_group_get_current_group()
  8. 8.8 modules/social_features/social_group/social_group.module \_social_group_get_current_group()
  9. 10.3.x modules/social_features/social_group/social_group.module \_social_group_get_current_group()
  10. 10.0.x modules/social_features/social_group/social_group.module \_social_group_get_current_group()
  11. 10.1.x modules/social_features/social_group/social_group.module \_social_group_get_current_group()
  12. 10.2.x modules/social_features/social_group/social_group.module \_social_group_get_current_group()

Get current Group entity from the route.

Return value

\Drupal\group\Entity\GroupInterface Returns the group object.

25 calls to _social_group_get_current_group()
GroupAddEventBlock::blockAccess in modules/social_features/social_group/src/Plugin/Block/GroupAddEventBlock.php
Custom access logic to display the block.
GroupAddEventBlock::build in modules/social_features/social_group/src/Plugin/Block/GroupAddEventBlock.php
Builds and returns the renderable array for this block plugin.
GroupAddTopicBlock::blockAccess in modules/social_features/social_group/src/Plugin/Block/GroupAddTopicBlock.php
Custom access logic to display the block.
GroupAddTopicBlock::build in modules/social_features/social_group/src/Plugin/Block/GroupAddTopicBlock.php
Builds and returns the renderable array for this block plugin.
GroupHeroBlock::build in modules/social_features/social_group/src/Plugin/Block/GroupHeroBlock.php
Builds and returns the renderable array for this block plugin.

... See full list

File

modules/social_features/social_group/social_group.module, line 906
The Social group module.

Code

function _social_group_get_current_group($node = NULL) {
  $group = \Drupal::routeMatch()
    ->getParameter('group');
  if (!is_object($group) && !is_null($group)) {
    $group = \Drupal::entityTypeManager()
      ->getStorage('group')
      ->load($group);
  }
  else {
    $node = is_object($node) ? $node : \Drupal::routeMatch()
      ->getParameter('node');
    if (is_object($node) && !is_null($node)) {
      $node_entity = [
        'target_type' => 'node',
        'target_id' => $node
          ->id(),
      ];
      $gid_from_entity = SocialGroupHelperService::getGroupFromEntity($node_entity);
      if ($gid_from_entity !== NULL) {
        $group = \Drupal::entityTypeManager()
          ->getStorage('group')
          ->load($gid_from_entity);
      }
    }
  }
  return $group;
}