public function NodePreviewController::view in Drupal 9
Same name and namespace in other branches
- 8 core/modules/node/src/Controller/NodePreviewController.php \Drupal\node\Controller\NodePreviewController::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
1 string reference to 'NodePreviewController::view'
- node.routing.yml in core/
modules/ node/ node.routing.yml - core/modules/node/node.routing.yml
File
- core/
modules/ node/ src/ Controller/ NodePreviewController.php, line 53
Class
- NodePreviewController
- Defines a controller to render a single node in preview.
Namespace
Drupal\node\ControllerCode
public function view(EntityInterface $node_preview, $view_mode_id = 'full', $langcode = NULL) {
$node_preview->preview_view_mode = $view_mode_id;
$build = parent::view($node_preview, $view_mode_id);
$build['#attached']['library'][] = 'node/drupal.node.preview';
// Don't render cache previews.
unset($build['#cache']);
return $build;
}