You are here

public static function FlexibleGroupContentVisibilityUpdate::getPostsFromGroup in Open Social 8.7

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::getPostsFromGroup()
  2. 8.6 modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::getPostsFromGroup()
  3. 8.8 modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::getPostsFromGroup()
  4. 10.3.x modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::getPostsFromGroup()
  5. 10.0.x modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::getPostsFromGroup()
  6. 10.1.x modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::getPostsFromGroup()
  7. 10.2.x modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php \Drupal\social_group_flexible_group\FlexibleGroupContentVisibilityUpdate::getPostsFromGroup()

Load all Posts based on a certain group.

Parameters

\Drupal\group\Entity\Group $group: The Group where we should check our posts for.

Return value

\Drupal\Core\Entity\EntityInterface[]|\Drupal\social_post\Entity\Post[] Returning the Posts that are part of a Group.

1 call to FlexibleGroupContentVisibilityUpdate::getPostsFromGroup()
FlexibleGroupContentVisibilityUpdate::batchUpdateGroupContentVisibility in modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php
Update Group content after Group changed.

File

modules/social_features/social_group/modules/social_group_flexible_group/src/FlexibleGroupContentVisibilityUpdate.php, line 182

Class

FlexibleGroupContentVisibilityUpdate
Class FlexibleGroupContentVisibilityUpdate.

Namespace

Drupal\social_group_flexible_group

Code

public static function getPostsFromGroup(Group $group) {
  $posts =& drupal_static(__FUNCTION__);
  if (!isset($posts)) {

    // Posts aren't marked as group content so we load them separately.
    $query = \Drupal::database()
      ->select('post__field_recipient_group', 'pst');
    $query
      ->addField('pst', 'entity_id');
    $query
      ->condition('pst.field_recipient_group_target_id', $group
      ->id());
    $query
      ->execute()
      ->fetchAll();
    $post_keys = $query
      ->execute()
      ->fetchAllAssoc('entity_id');

    // Store all the post entity ids.
    $post_ids = array_keys($post_keys);
    $posts = Post::loadMultiple($post_ids);
  }
  return $posts;
}