public function OwnerActivityContext::getRecipientOwnerFromEntity in Open Social 8
Same name and namespace in other branches
- 8.9 modules/custom/activity_basics/src/Plugin/ActivityContext/OwnerActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\OwnerActivityContext::getRecipientOwnerFromEntity()
- 8.2 modules/custom/activity_basics/src/Plugin/ActivityContext/OwnerActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\OwnerActivityContext::getRecipientOwnerFromEntity()
- 8.3 modules/custom/activity_basics/src/Plugin/ActivityContext/OwnerActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\OwnerActivityContext::getRecipientOwnerFromEntity()
- 8.4 modules/custom/activity_basics/src/Plugin/ActivityContext/OwnerActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\OwnerActivityContext::getRecipientOwnerFromEntity()
- 8.5 modules/custom/activity_basics/src/Plugin/ActivityContext/OwnerActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\OwnerActivityContext::getRecipientOwnerFromEntity()
- 8.6 modules/custom/activity_basics/src/Plugin/ActivityContext/OwnerActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\OwnerActivityContext::getRecipientOwnerFromEntity()
- 8.7 modules/custom/activity_basics/src/Plugin/ActivityContext/OwnerActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\OwnerActivityContext::getRecipientOwnerFromEntity()
- 8.8 modules/custom/activity_basics/src/Plugin/ActivityContext/OwnerActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\OwnerActivityContext::getRecipientOwnerFromEntity()
- 10.3.x modules/custom/activity_basics/src/Plugin/ActivityContext/OwnerActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\OwnerActivityContext::getRecipientOwnerFromEntity()
- 10.0.x modules/custom/activity_basics/src/Plugin/ActivityContext/OwnerActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\OwnerActivityContext::getRecipientOwnerFromEntity()
- 10.1.x modules/custom/activity_basics/src/Plugin/ActivityContext/OwnerActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\OwnerActivityContext::getRecipientOwnerFromEntity()
- 10.2.x modules/custom/activity_basics/src/Plugin/ActivityContext/OwnerActivityContext.php \Drupal\activity_basics\Plugin\ActivityContext\OwnerActivityContext::getRecipientOwnerFromEntity()
Returns owner recipient from entity.
1 call to OwnerActivityContext::getRecipientOwnerFromEntity()
- OwnerActivityContext::getRecipients in modules/
custom/ activity_basics/ src/ Plugin/ ActivityContext/ OwnerActivityContext.php - Returns a batched list of recipients for this context.
File
- modules/
custom/ activity_basics/ src/ Plugin/ ActivityContext/ OwnerActivityContext.php, line 39
Class
- OwnerActivityContext
- Provides a 'OwnerActivityContext' activity context.
Namespace
Drupal\activity_basics\Plugin\ActivityContextCode
public function getRecipientOwnerFromEntity(array $related_entity, array $data) {
$recipients = [];
$entity_storage = \Drupal::entityTypeManager()
->getStorage($related_entity['target_type']);
$entity = $entity_storage
->load($related_entity['target_id']);
// Don't return recipients if user comments on own content.
$original_related_object = $data['related_object'][0];
if (isset($original_related_object['target_type']) && $original_related_object['target_type'] == 'comment') {
$storage = \Drupal::entityTypeManager()
->getStorage($original_related_object['target_type']);
$original_related_entity = $storage
->load($original_related_object['target_id']);
if (!empty($original_related_entity) && $original_related_entity
->getOwnerId() == $entity
->getOwnerId()) {
return $recipients;
}
}
$recipients[] = [
'target_type' => 'user',
'target_id' => $entity
->getOwnerId(),
];
return $recipients;
}