You are here

function user_hooks_test_user_format_name_alter in Drupal 9

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().

8 string references to 'user_hooks_test_user_format_name_alter'
CommentAttributesTest::testCommentRdfaMarkup in core/modules/rdf/tests/src/Functional/CommentAttributesTest.php
Tests if RDFa markup for meta information is present in comments.
CommentAttributesTest::testCommentRdfAuthorMarkup in core/modules/rdf/tests/src/Functional/CommentAttributesTest.php
Tests comment author link markup has not been broken by RDF.
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.
UserAttributesTest::setUp in core/modules/rdf/tests/src/Functional/UserAttributesTest.php

... See full list

File

core/modules/user/tests/modules/user_hooks_test/user_hooks_test.module, line 14
Support module for user hooks testing.

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>';
    }
  }
}