You are here

public function RenderedEntity::view in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/EntityBrowser/FieldWidgetDisplay/RenderedEntity.php \Drupal\entity_browser\Plugin\EntityBrowser\FieldWidgetDisplay\RenderedEntity::view()

Builds and gets render array for the entity.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: Entity to be displayed.

Return value

array Render array that is to be used to display the entity in field widget.

Overrides FieldWidgetDisplayInterface::view

File

src/Plugin/EntityBrowser/FieldWidgetDisplay/RenderedEntity.php, line 74

Class

RenderedEntity
Displays the fully rendered entity.

Namespace

Drupal\entity_browser\Plugin\EntityBrowser\FieldWidgetDisplay

Code

public function view(EntityInterface $entity) {
  $build = $this->entityTypeManager
    ->getViewBuilder($this->configuration['entity_type'])
    ->view($entity, $this->configuration['view_mode']);
  $build['#entity_browser_suppress_contextual'] = TRUE;
  $build['#cache']['keys'][] = 'entity_browser';
  return $build;
}