You are here

function advpoll_entity_view in Advanced Poll 8

Implements hook_entity_view().

File

./advpoll.module, line 67

Code

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

  // reset lazy loader in Poll to use our service which will allow specific form output per poll type
  if ($entity
    ->getEntityType()
    ->id() == 'poll') {
    $build['poll'] = array(
      '#lazy_builder' => [
        'advpoll.post_render_cache:renderViewForm',
        [
          'id' => $entity
            ->id(),
          'view_mode' => $view_mode,
          'langcode' => $entity
            ->language()
            ->getId(),
        ],
      ],
      '#create_placeholder' => TRUE,
      '#cache' => [
        'tags' => $entity
          ->getCacheTags(),
      ],
    );
  }
}