Created
June 28, 2016 14:04
-
-
Save basvdheijden/5ade4bcf7f2ed3c2dded26fe441d6fe6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function view(EntityInterface $node, $view_mode = 'full', $langcode = NULL) { | |
$page = $this->entityManager | |
->getViewBuilder($node->getEntityTypeId()) | |
->view($node, $view_mode); | |
$page['#pre_render'][] = [$this, 'buildTitle']; | |
$page['#entity_type'] = $node->getEntityTypeId(); | |
$page['#' . $page['#entity_type']] = $node; | |
$render_array = $page; | |
$render_context = new RenderContext(); | |
$result = $this->renderer->executeInRenderContext($render_context, function() use (&$render_array) { | |
return $this->renderer->renderRoot($render_array); | |
}); | |
$content = new HtmlResponse($result); | |
$content->addCacheableDependency($render_context); | |
return $content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment