public function FollowContentActivityContext::getRecipientsWhoFollowContent in Open Social 8
Same name and namespace in other branches
- 8.9 modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
- 8.2 modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
- 8.3 modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
- 8.4 modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
- 8.5 modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
- 8.6 modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
- 8.7 modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
- 8.8 modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
- 10.3.x modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
- 10.0.x modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
- 10.1.x modules/social_features/social_follow_content/src/Plugin/ActivityContext/FollowContentActivityContext.php \Drupal\social_follow_content\Plugin\ActivityContext\FollowContentActivityContext::getRecipientsWhoFollowContent()
- 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\ActivityContextCode
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;
}