You are here

function comment_view_multiple in Drupal 8

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

Constructs render array from an array of loaded comments.

Parameters

\Drupal\comment\CommentInterface[] $comments: An array of comments as returned by entity_load_multiple().

string $view_mode: (optional) View mode; for instance, 'full', 'teaser', etc. Defaults to 'full'.

string $langcode: (optional) A string indicating the language field values are to be shown in. If no language is provided the current content language is used. Defaults to NULL.

Return value

array An array in the format expected by \Drupal\Core\Render\RendererInterface::render().

Deprecated

in drupal:8.0.0 and is removed from drupal:9.0.0. Use \Drupal::entityTypeManager()->getViewBuilder('comment')->viewMultiple().

See also

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

\Drupal\Core\Render\RendererInterface::render()

1 call to comment_view_multiple()
CommentLegacyTest::testCommentView in core/modules/comment/tests/src/Kernel/CommentLegacyTest.php
@expectedDeprecation comment_view() is deprecated in Drupal 8.0.0 and will be removed before Drupal 9.0.0. Use \Drupal::entityTypeManager()->getViewBuilder('comment')->view() instead. See…

File

core/modules/comment/comment.module, line 312
Enables users to comment on published content.

Code

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