function user_view
Same name in other branches
- 7.x modules/user/user.module \user_view()
Generate an array for rendering the given user.
When viewing a user profile, the $page array contains:
- $page['content']['member_for']: Contains the default "Member for" profile data for a user.
- $page['content']['#user']: The user account of the profile being viewed.
To theme user profiles, copy core/modules/user/templates/user.html.twig to your theme directory, and edit it as instructed in that file's comments.
Parameters
\Drupal\user\UserInterface $account: A user object.
string $view_mode: View mode, e.g. 'full'.
string|null $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.7.0 and is removed from drupal:9.0.0. Use \Drupal::entityTypeManager()->getViewBuilder('user')->view() instead.
See also
https://www.drupal.org/node/3033656
1 call to user_view()
- UserLegacyTest::testUserView in core/
modules/ user/ tests/ src/ Kernel/ UserLegacyTest.php - @expectedDeprecation user_view() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \Drupal::entityTypeManager()->getViewBuilder('user')->view() instead. Seeā¦
6 string references to 'user_view'
- CommentCacheTagsTest::getAdditionalCacheTagsForEntity in core/
modules/ comment/ tests/ src/ Functional/ CommentCacheTagsTest.php - Each comment must have a comment body, which always has a text format.
- CommentDefaultFormatterCacheTagsTest::testCacheTags in core/
modules/ comment/ tests/ src/ Kernel/ CommentDefaultFormatterCacheTagsTest.php - Tests the bubbling of cache tags.
- FrontPageTest::doTestFrontPageViewCacheTags in core/
modules/ node/ tests/ src/ Functional/ Views/ FrontPageTest.php - Tests the cache tags on the front page.
- NodeCacheTagsTest::getAdditionalCacheTagsForEntity in core/
modules/ node/ tests/ src/ Functional/ NodeCacheTagsTest.php - Each node must have an author.
- RouterTest::testMatchesWithDifferentFitOrder in core/
tests/ Drupal/ Tests/ Core/ Routing/ RouterTest.php - @covers ::applyFitOrder
File
-
core/
modules/ user/ user.module, line 963
Code
function user_view($account, $view_mode = 'full', $langcode = NULL) {
@trigger_error("user_view() is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. Use \\Drupal::entityTypeManager()->getViewBuilder('user')->view() instead. See https://www.drupal.org/node/3033656", E_USER_DEPRECATED);
return \Drupal::entityTypeManager()->getViewBuilder('user')
->view($account, $view_mode, $langcode);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.