function rules_entity_view

Implements hook_entity_view().

File

./rules.module, line 120

Code

function rules_entity_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
  // Only handle content entities and ignore config entities.
  if ($entity instanceof ContentEntityInterface) {
    $entity_type_id = $entity->getEntityTypeId();
    $event = new EntityEvent($entity, [
      $entity_type_id => $entity,
    ]);
    $event_dispatcher = \Drupal::service('event_dispatcher');
    $event_dispatcher->dispatch($event, "rules_entity_view:{$entity_type_id}");
  }
}