You are here

public function MentionActivityContext::isValidEntity in Open Social 10.2.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::isValidEntity()
  2. 8 modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::isValidEntity()
  3. 8.2 modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::isValidEntity()
  4. 8.3 modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::isValidEntity()
  5. 8.4 modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::isValidEntity()
  6. 8.5 modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::isValidEntity()
  7. 8.6 modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::isValidEntity()
  8. 8.7 modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::isValidEntity()
  9. 8.8 modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::isValidEntity()
  10. 10.3.x modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::isValidEntity()
  11. 10.0.x modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::isValidEntity()
  12. 10.1.x modules/social_features/social_mentions/src/Plugin/ActivityContext/MentionActivityContext.php \Drupal\social_mentions\Plugin\ActivityContext\MentionActivityContext::isValidEntity()

Check for valid entity.

Overrides ActivityContextBase::isValidEntity

File

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

Class

MentionActivityContext
Provides a 'MentionActivityContext' activity context.

Namespace

Drupal\social_mentions\Plugin\ActivityContext

Code

public function isValidEntity(EntityInterface $entity) {
  if ($entity
    ->getEntityTypeId() === 'mentions') {
    return TRUE;
  }

  // Special cases for comments and posts.
  $allowed_content_types = [
    'comment',
  ];
  if (in_array($entity
    ->getEntityTypeId(), $allowed_content_types)) {
    $mentions = $this
      ->getMentionsFromRelatedEntity($entity);
    if (!empty($mentions)) {
      return TRUE;
    }
  }
  return FALSE;
}