EntityViewController::view

public EntityViewController::view(EntityInterface $_entity, $view_mode = 'full')

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().

File

core/lib/Drupal/Core/Entity/Controller/EntityViewController.php, line 93

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;
}
doc_Drupal
2016-10-29 09:08:50
Comments
Leave a Comment

Please login to continue.