You are here

function social_mentions_preprocess_mentions in Open Social 8.8

Same name and namespace in other branches
  1. 8.9 modules/social_features/social_mentions/social_mentions.module \social_mentions_preprocess_mentions()
  2. 8 modules/social_features/social_mentions/social_mentions.module \social_mentions_preprocess_mentions()
  3. 8.2 modules/social_features/social_mentions/social_mentions.module \social_mentions_preprocess_mentions()
  4. 8.3 modules/social_features/social_mentions/social_mentions.module \social_mentions_preprocess_mentions()
  5. 8.4 modules/social_features/social_mentions/social_mentions.module \social_mentions_preprocess_mentions()
  6. 8.5 modules/social_features/social_mentions/social_mentions.module \social_mentions_preprocess_mentions()
  7. 8.6 modules/social_features/social_mentions/social_mentions.module \social_mentions_preprocess_mentions()
  8. 8.7 modules/social_features/social_mentions/social_mentions.module \social_mentions_preprocess_mentions()
  9. 10.3.x modules/social_features/social_mentions/social_mentions.module \social_mentions_preprocess_mentions()
  10. 10.0.x modules/social_features/social_mentions/social_mentions.module \social_mentions_preprocess_mentions()
  11. 10.1.x modules/social_features/social_mentions/social_mentions.module \social_mentions_preprocess_mentions()
  12. 10.2.x modules/social_features/social_mentions/social_mentions.module \social_mentions_preprocess_mentions()

Implements hook_preprocess_hook().

File

modules/social_features/social_mentions/social_mentions.module, line 80
Contains social_mentions.module.

Code

function social_mentions_preprocess_mentions(&$variables) {
  if (!empty($variables['elements']['#mentions'])) {
    $mention = $variables['elements']['#mentions'];
    if (isset($mention->entity_type)) {
      $entity_type = $mention
        ->getMentionedEntityTypeId();
      $entity = $mention
        ->getMentionedEntity();
      if ($entity) {
        $content = \Drupal::entityTypeManager()
          ->getViewBuilder($entity_type)
          ->view($entity, 'activity');
        $variables['mention_context'] = $content;
      }
    }
  }
}