You are here

function _social_group_get_current_group in Open Social 8.3

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 modules/social_features/social_group/social_group.module \_social_group_get_current_group()
  3. 8.2 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.

28 calls to _social_group_get_current_group()
GroupAddBookBlock::blockAccess in modules/social_features/social_book/src/Plugin/Block/GroupAddBookBlock.php
Custom access logic to display the block.
GroupAddBookBlock::build in modules/social_features/social_book/src/Plugin/Block/GroupAddBookBlock.php
Builds and returns the renderable array for this block plugin.
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.

... See full list

File

modules/social_features/social_group/social_group.module, line 848
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;
}