user_hooks_test.module

Same filename in other branches
  1. 9 core/modules/user/tests/modules/user_hooks_test/user_hooks_test.module
  2. 8.9.x core/modules/user/tests/modules/user_hooks_test/user_hooks_test.module
  3. 10 core/modules/user/tests/modules/user_hooks_test/user_hooks_test.module

File

core/modules/user/tests/modules/user_hooks_test/user_hooks_test.module

View source
<?php


/**
 * @file
 * Support module for user hooks testing.
 */
declare (strict_types=1);
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Session\AccountInterface;

/**
 * Implements hook_user_format_name_alter().
 */
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>';
        }
    }
}

Functions

Title Deprecated Summary
user_hooks_test_user_format_name_alter Implements hook_user_format_name_alter().

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