function user_hooks_test_user_format_name_alter

Same name in other branches
  1. 9 core/modules/user/tests/modules/user_hooks_test/user_hooks_test.module \user_hooks_test_user_format_name_alter()
  2. 8.9.x core/modules/user/tests/modules/user_hooks_test/user_hooks_test.module \user_hooks_test_user_format_name_alter()
  3. 10 core/modules/user/tests/modules/user_hooks_test/user_hooks_test.module \user_hooks_test_user_format_name_alter()

Implements hook_user_format_name_alter().

5 string references to 'user_hooks_test_user_format_name_alter'
CommentPreviewTest::testCommentPreview in core/modules/comment/tests/src/Functional/CommentPreviewTest.php
Tests comment preview.
TrackerTest::testTrackerUser in core/modules/tracker/tests/src/Functional/TrackerTest.php
Tests for the presence of nodes on a user's tracker listing.
UserEditTest::testUserEdit in core/modules/user/tests/src/Functional/UserEditTest.php
Tests user edit page.
UserEntityLabelTest::testLabelCallback in core/modules/user/tests/src/Kernel/UserEntityLabelTest.php
Tests label callback.
UserTokenReplaceTest::testUserTokenReplacement in core/modules/user/tests/src/Functional/UserTokenReplaceTest.php
Creates a user, then tests the tokens generated from it.

File

core/modules/user/tests/modules/user_hooks_test/user_hooks_test.module, line 16

Code

function user_hooks_test_user_format_name_alter(&$name, AccountInterface $account) {
    if (\Drupal::state()->get('user_hooks_test_user_format_name_alter', FALSE)) {
        if (\Drupal::state()->get('user_hooks_test_user_format_name_alter_safe', FALSE)) {
            $name = new FormattableMarkup('<em>@uid</em>', [
                '@uid' => $account->id(),
            ]);
        }
        else {
            $name = '<em>' . $account->id() . '</em>';
        }
    }
}

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