class UserFieldHooks
Field and Field UI hook implementations for User module.
Hierarchy
- class \Drupal\user\Hook\UserFieldHooks uses \Drupal\Core\StringTranslation\StringTranslationTrait
Expanded class hierarchy of UserFieldHooks
File
-
core/
modules/ user/ src/ Hook/ UserFieldHooks.php, line 15
Namespace
Drupal\user\HookView source
class UserFieldHooks {
use StringTranslationTrait;
public function __construct(protected readonly FieldTypePluginManagerInterface $fieldTypeManager) {
}
/**
* Implements hook_field_ui_preconfigured_options_alter().
*/
public function preConfiguredDescription(array &$options, $field_type) : void {
// If the field is not an "entity_reference"-based field, then bail out.
$class = $this->fieldTypeManager
->getPluginClass($field_type);
if (!is_a($class, EntityReferenceItem::class, TRUE)) {
return;
}
// Set the description for the "Add field" page.
if (!empty($options['user'])) {
$options['user']['description'] = [
$this->t('Refer to any user on the site'),
$this->t("Examples: show the user's email address or a link to their contact form"),
];
}
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary | Overrides |
|---|---|---|---|---|
| StringTranslationTrait::$stringTranslation | protected | property | The string translation service. | 3 |
| StringTranslationTrait::formatPlural | protected | function | Formats a string containing a count of items. | |
| StringTranslationTrait::getNumberOfPlurals | protected | function | Returns the number of plurals supported by a given language. | |
| StringTranslationTrait::getStringTranslation | protected | function | Gets the string translation service. | |
| StringTranslationTrait::setStringTranslation | public | function | Sets the string translation service to use. | 2 |
| StringTranslationTrait::t | protected | function | Translates a string to the current language or to a given language. | 1 |
| UserFieldHooks::preConfiguredDescription | public | function | Implements hook_field_ui_preconfigured_options_alter(). | |
| UserFieldHooks::__construct | public | function |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.