You are here

function node_view_multiple in Drupal 8

Same name and namespace in other branches
  1. 7 modules/node/node.module \node_view_multiple()

Constructs a drupal_render() style array from an array of loaded nodes.

Parameters

$nodes: An array of nodes as returned by Node::loadMultiple().

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

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

Return value

array An array in the format 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')->viewMultiple() instead.

See also

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

1 call to node_view_multiple()
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…

File

core/modules/node/node.module, line 895
The core module that allows content to be submitted to the site.

Code

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