You are here

function user_hooks_test_user_format_name_alter in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 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().

4 string references to 'user_hooks_test_user_format_name_alter'
CommentPreviewTest::testCommentPreview in core/modules/comment/src/Tests/CommentPreviewTest.php
Tests comment preview.
TrackerTest::testTrackerUser in core/modules/tracker/src/Tests/TrackerTest.php
Tests for the presence of nodes on a user's tracker listing.
UserEntityCallbacksTest::testLabelCallback in core/modules/user/src/Tests/UserEntityCallbacksTest.php
Test label callback.
UserTokenReplaceTest::testUserTokenReplacement in core/modules/user/src/Tests/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 13
Support module for user hooks testing.

Code

function user_hooks_test_user_format_name_alter(&$name, $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 = SafeMarkup::format('<em>@uid</em>', array(
        '@uid' => $account
          ->id(),
      ));
    }
    else {
      $name = '<em>' . $account
        ->id() . '</em>';
    }
  }
}