function LocaleTestHooks::userView

Same name and namespace in other branches
  1. main core/modules/locale/tests/modules/locale_test/src/Hook/LocaleTestHooks.php \Drupal\locale_test\Hook\LocaleTestHooks::userView()

Implements hook_ENTITY_TYPE_view() for user entities.

Attributes

#[Hook('user_view')]

File

core/modules/locale/tests/modules/locale_test/src/Hook/LocaleTestHooks.php, line 240

Class

LocaleTestHooks
Hook implementations for locale_test.

Namespace

Drupal\locale_test\Hook

Code

public function userView(array &$build, UserInterface $account, EntityViewDisplayInterface $display) : void {
  if ($account->isAuthenticated() && $display->getComponent('translatable_text')) {
    $build['translatable_text'] = [
      '#markup' => $this->t('This is translatable text'),
    ];
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.