You are here

public function MentionActivityContext::getMentionsFromRelatedEntity in Open Social 10.1.x

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

Get the mentions from the related entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity object.

Return value

\Drupal\Core\Entity\EntityInterface[] The mentions.

2 calls to MentionActivityContext::getMentionsFromRelatedEntity()
MentionActivityContext::getRecipients in modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php
Returns a batched list of recipients for this context.
MentionActivityContext::isValidEntity in modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php
Check for valid entity.

File

modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php, line 104

Class

MentionActivityContext
Provides a 'MentionActivityContext' activity context.

Namespace

Drupal\social_mentions\Plugin\ActivityContext

Code

public function getMentionsFromRelatedEntity(EntityInterface $entity) {
  if ($entity
    ->getEntityTypeId() === 'comment') {
    if ($entity
      ->hasParentComment()) {
      $entity = $entity
        ->getParentComment();
    }
  }

  // Mention entity can't be loaded at time of new post or comment creation.
  return $this->entityTypeManager
    ->getStorage('mentions')
    ->loadByProperties([
    'entity_type' => $entity
      ->getEntityTypeId(),
    'entity_id' => $entity
      ->id(),
  ]);
}