function NodePreviewController::view

Same name in other branches
  1. 8.9.x core/modules/node/src/Controller/NodePreviewController.php \Drupal\node\Controller\NodePreviewController::view()
  2. 10 core/modules/node/src/Controller/NodePreviewController.php \Drupal\node\Controller\NodePreviewController::view()
  3. 11.x core/modules/node/src/Controller/NodePreviewController.php \Drupal\node\Controller\NodePreviewController::view()

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\Controller

Code

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;
}

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