You are here

public function FollowContentActivityContext::getRecipientsWhoFollowContent in Open Social 8.2

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
  2. 8 modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
  3. 8.3 modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
  4. 8.4 modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
  5. 8.5 modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
  6. 8.6 modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
  7. 8.7 modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
  8. 8.8 modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
  9. 10.3.x modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
  10. 10.0.x modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
  11. 10.1.x modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
  12. 10.2.x modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()

Returns owner recipient from entity.

1 call to FollowContentActivityContext::getRecipientsWhoFollowContent()
FollowContentActivityContext::getRecipients in modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php
Returns a batched list of recipients for this context.

File

modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php, line 39

Class

FollowContentActivityContext
Provides a 'FollowContentActivityContext' activity context plugin.

Namespace

Drupal\social_follow_content\Plugin\ActivityContext

Code

public function getRecipientsWhoFollowContent(array $related_entity, array $data) {
  $recipients = [];
  $storage = \Drupal::entityTypeManager()
    ->getStorage('flagging');
  $flaggings = $storage
    ->loadByProperties([
    'flag_id' => 'follow_content',
    'entity_type' => $related_entity['target_type'],
    'entity_id' => $related_entity['target_id'],
  ]);

  // We don't send notifications to users about their own comments.
  $original_related_object = $data['related_object'][0];
  $storage = \Drupal::entityTypeManager()
    ->getStorage($original_related_object['target_type']);
  $original_related_entity = $storage
    ->load($original_related_object['target_id']);
  foreach ($flaggings as $flagging) {
    $recipient = $flagging
      ->getOwner();
    if ($recipient
      ->id() != $original_related_entity
      ->getOwnerId()) {
      if ($original_related_entity
        ->access('view', $recipient)) {
        $recipients[] = [
          'target_type' => 'user',
          'target_id' => $recipient
            ->id(),
        ];
      }
    }
  }
  return $recipients;
}