You are here

function activity_creator_entity_view in Open Social 10.0.x

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

Implements hook_entity_view().

Mark notifications as read.

File

modules/custom/activity_creator/activity_creator.module, line 270
Activity Creator module file.

Code

function activity_creator_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {

  // Generate the output text for the user in it's selected language.
  if ($entity instanceof Activity && !empty($entity
    ->get('field_activity_message')->target_id)) {
    $message = Message::load($entity
      ->get('field_activity_message')->target_id);
    if ($message instanceof Message) {

      // Get the text in the users language.
      $output = \Drupal::service('activity_creator.activity_factory')
        ->getMessageText($message);

      // Replace the old text with the correct one.
      $build['field_activity_output_text'][0]['#text'] = $output[0];
    }
  }
}