public function MediaViewController::view in Media Expire 8
Same name and namespace in other branches
- 8.2 src/Controller/MediaViewController.php \Drupal\media_expire\Controller\MediaViewController::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\Core\Render\RendererInterface::render().
Overrides EntityViewController::view
File
- src/
Controller/ MediaViewController.php, line 16
Class
- MediaViewController
- Extends EntityViewController to overwrite the view method.
Namespace
Drupal\media_expire\ControllerCode
public function view(EntityInterface $media, $view_mode = 'full') {
$page = $this->entityManager
->getViewBuilder($media
->getEntityTypeId())
->view($media, $view_mode);
$page['#pre_render'][] = [
$this,
'buildTitle',
];
$page['#entity_type'] = $media
->getEntityTypeId();
if (empty($page['#' . $page['#entity_type']])) {
$page['#' . $page['#entity_type']] = $media;
}
return $page;
}