function EntityRevisionViewController::__invoke

Same name in other branches
  1. 11.x core/lib/Drupal/Core/Entity/Controller/EntityRevisionViewController.php \Drupal\Core\Entity\Controller\EntityRevisionViewController::__invoke()

Provides a page to render a single entity revision.

Parameters

\Drupal\Core\Entity\RevisionableInterface $_entity_revision: The Entity to be rendered. Note this variable is named $_entity_revision 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.

File

core/lib/Drupal/Core/Entity/Controller/EntityRevisionViewController.php, line 70

Class

EntityRevisionViewController
Defines a controller to view an entity revision.

Namespace

Drupal\Core\Entity\Controller

Code

public function __invoke(RevisionableInterface $_entity_revision, string $view_mode = 'full') : array {
    $entityTypeId = $_entity_revision->getEntityTypeId();
    $page = $this->entityTypeManager
        ->getViewBuilder($entityTypeId)
        ->view($_entity_revision, $view_mode);
    $page['#entity_type'] = $entityTypeId;
    $page['#' . $entityTypeId] = $_entity_revision;
    return $page;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.