You are here

public function EntityViewController::view in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Entity/Controller/EntityViewController.php \Drupal\Core\Entity\Controller\EntityViewController::view()

Provides a page to render a single entity.

Parameters

\Drupal\Core\Entity\EntityInterface $_entity: The Entity to be rendered. Note this variable is named $_entity rather than $entity to prevent collisions with other named placeholders in the route.

string $view_mode: (optional) The view mode that should be used to display the entity. Defaults to 'full'.

Return value

array A render array as expected by drupal_render().

2 calls to EntityViewController::view()
NodePreviewController::view in core/modules/node/src/Controller/NodePreviewController.php
Provides a page to render a single entity.
NodeViewController::view in core/modules/node/src/Controller/NodeViewController.php
Provides a page to render a single entity.
2 methods override EntityViewController::view()
NodePreviewController::view in core/modules/node/src/Controller/NodePreviewController.php
Provides a page to render a single entity.
NodeViewController::view in core/modules/node/src/Controller/NodeViewController.php
Provides a page to render a single entity.

File

core/lib/Drupal/Core/Entity/Controller/EntityViewController.php, line 98
Contains \Drupal\Core\Entity\Controller\EntityViewController.

Class

EntityViewController
Defines a generic controller to render a single entity.

Namespace

Drupal\Core\Entity\Controller

Code

public function view(EntityInterface $_entity, $view_mode = 'full') {
  $page = $this->entityManager
    ->getViewBuilder($_entity
    ->getEntityTypeId())
    ->view($_entity, $view_mode);
  $page['#pre_render'][] = [
    $this,
    'buildTitle',
  ];
  $page['#entity_type'] = $_entity
    ->getEntityTypeId();
  $page['#' . $page['#entity_type']] = $_entity;
  return $page;
}