class TaxonomyFieldHooks

Field and Field UI hook implementations for Taxonomy module.

Hierarchy

Expanded class hierarchy of TaxonomyFieldHooks

File

core/modules/taxonomy/src/Hook/TaxonomyFieldHooks.php, line 15

Namespace

Drupal\taxonomy\Hook
View source
class TaxonomyFieldHooks {
  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['taxonomy_term'])) {
      $options['taxonomy_term']['description'] = [
        $this->t('Attach a term from any vocabulary'),
        $this->t('Examples: free tag, site section, article topic'),
      ];
    }
  }

}

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
TaxonomyFieldHooks::preConfiguredDescription public function Implements hook_field_ui_preconfigured_options_alter().
TaxonomyFieldHooks::__construct public function

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