The user's account information is being displayed.
The module should format its custom additions for display and add them to the $account->content array.
\Drupal\user\UserInterface $account: The user object on which the operation is being performed.
\Drupal\entity\Plugin\Core\Entity\EntityDisplay $display: The entity_display object holding the display options configured for the user components.
$view_mode: View mode, e.g. 'full'.
$langcode: The language code used for rendering.
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
function hook_user_view(\Drupal\user\UserInterface $account, \Drupal\entity\Plugin\Core\Entity\EntityDisplay $display, $view_mode, $langcode) {
// Only do the extra work if the component is configured to be displayed.
// This assumes a 'mymodule_addition' extra field has been defined for the
// user entity type in hook_field_extra_fields().
if ($display
->getComponent('mymodule_addition')) {
$account->content['mymodule_addition'] = array(
'#markup' => mymodule_addition($account),
'#theme' => 'mymodule_my_additional_field',
);
}
}