function node_view

Same name in other branches
  1. 7.x modules/node/node.module \node_view()

Generates an array for rendering the given node.

Parameters

\Drupal\node\NodeInterface $node: A node entity.

$view_mode: (optional) View mode, e.g., 'full', 'teaser', etc. Defaults to 'full.'

$langcode: (optional) A language code to use for rendering. Defaults to NULL which is the global content language of the current request.

Return value

array An array as expected by \Drupal\Core\Render\RendererInterface::render().

Deprecated

in drupal:8.7.0 and is removed from drupal:9.0.0. Use \Drupal::entityTypeManager()->getViewBuilder('node')->view() instead.

See also

https://www.drupal.org/node/3033656

1 call to node_view()
NodeLegacyTest::testNodeView in core/modules/node/tests/src/Kernel/NodeLegacyTest.php
@expectedDeprecation node_view() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \Drupal::entityTypeManager()->getViewBuilder('node')->view() instead. Seeā€¦
7 string references to 'node_view'
CommentRssTest::testCommentRss in core/modules/comment/tests/src/Functional/CommentRssTest.php
Tests comments as part of an RSS feed.
FrontPageTest::doTestFrontPageViewCacheTags in core/modules/node/tests/src/Functional/Views/FrontPageTest.php
Tests the cache tags on the front page.
PageCacheTagsIntegrationTest::testPageCacheTags in core/modules/page_cache/tests/src/Functional/PageCacheTagsIntegrationTest.php
Test that cache tags are properly bubbled up to the page level.
SearchPageCacheTagsTest::testSearchTagsBubbling in core/modules/search/tests/src/Functional/SearchPageCacheTagsTest.php
Tests the presence of expected cache tags with referenced entities.
UrlTest::setUp in core/tests/Drupal/Tests/Core/UrlTest.php

... See full list

File

core/modules/node/node.module, line 867

Code

function node_view(NodeInterface $node, $view_mode = 'full', $langcode = NULL) {
    @trigger_error("node_view() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \\Drupal::entityTypeManager()->getViewBuilder('node')->view() instead. See https://www.drupal.org/node/3033656", E_USER_DEPRECATED);
    return \Drupal::entityTypeManager()->getViewBuilder('node')
        ->view($node, $view_mode, $langcode);
}

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