function comment_view in Drupal 8
Same name and namespace in other branches
- 7 modules/comment/comment.module \comment_view()
Generates an array for rendering a comment.
Parameters
\Drupal\comment\CommentInterface $comment: The comment object.
string $view_mode: (optional) View mode; for instance, 'full', 'teaser', etc. Defaults to 'full'.
string $langcode: (optional) A language code to use for rendering. Defaults to 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.0.0 and is removed from drupal:9.0.0. Use \Drupal::entityTypeManager()->getViewBuilder('comment')->view().
See also
https://www.drupal.org/node/3033656
1 call to comment_view()
- 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…
1 string reference to 'comment_view'
- CommentDefaultFormatterCacheTagsTest::testCacheTags in core/
modules/ comment/ tests/ src/ Kernel/ CommentDefaultFormatterCacheTagsTest.php - Tests the bubbling of cache tags.
File
- core/
modules/ comment/ comment.module, line 282 - Enables users to comment on published content.
Code
function comment_view(CommentInterface $comment, $view_mode = 'full', $langcode = NULL) {
@trigger_error("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 https://www.drupal.org/node/3033656", E_USER_DEPRECATED);
return \Drupal::entityTypeManager()
->getViewBuilder('comment')
->view($comment, $view_mode, $langcode);
}