public function MentionActivityContext::getRecipients in Open Social 8.5
Same name and namespace in other branches
- 8.9 modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::getRecipients()
- 8 modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::getRecipients()
- 8.2 modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::getRecipients()
- 8.3 modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::getRecipients()
- 8.4 modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::getRecipients()
- 8.6 modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::getRecipients()
- 8.7 modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::getRecipients()
- 8.8 modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::getRecipients()
- 10.3.x modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::getRecipients()
- 10.0.x modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::getRecipients()
- 10.1.x modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::getRecipients()
- 10.2.x modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::getRecipients()
Returns a batched list of recipients for this context.
Format array( array ( id = uid or gip type = "user / group" ) )
Overrides ActivityContextBase::getRecipients
File
- modules/
social_features/ social_mentions/ src/ Plugin/ ActivityContext/ MentionActivityContext.php, line 21
Class
- MentionActivityContext
- Provides a 'MentionActivityContext' activity context.
Namespace
Drupal\social_mentions\Plugin\ActivityContextCode
public function getRecipients(array $data, $last_uid, $limit) {
$recipients = [];
$mentions = [];
// We only know the context if there is a related object.
if (isset($data['related_object']) && !empty($data['related_object'])) {
$related_object = $data['related_object'][0];
$mentions_storage = \Drupal::entityTypeManager()
->getStorage('mentions');
if ($related_object['target_type'] == 'mentions') {
$mentions[] = $mentions_storage
->load($related_object['target_id']);
}
else {
$entity_storage = \Drupal::entityTypeManager()
->getStorage($related_object['target_type']);
$entity = $entity_storage
->load($related_object['target_id']);
$mentions = $this
->getMentionsFromRelatedEntity($entity);
}
if (!empty($mentions)) {
foreach ($mentions as $mention) {
if (isset($mention->uid)) {
$uid = $mention
->getMentionedUserId();
// Don't send notifications to myself.
if ($uid === $data['actor']) {
continue;
}
$entity_storage = \Drupal::entityTypeManager()
->getStorage($mention
->getMentionedEntityTypeId());
$mentioned_entity = $entity_storage
->load($mention
->getMentionedEntityId());
$account = User::load($uid);
$access = $mentioned_entity
->access('view', $account);
if ($access) {
$recipients[] = [
'target_type' => 'user',
'target_id' => $mention
->getMentionedUserId(),
];
}
}
}
}
}
return $recipients;
}