class NodeFieldHooks

Field and Field UI hook implementations for Node module.

Hierarchy

Expanded class hierarchy of NodeFieldHooks

File

core/modules/node/src/Hook/NodeFieldHooks.php, line 15

Namespace

Drupal\node\Hook
View source
class NodeFieldHooks {
  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['node'])) {
      $options['node']['description'] = [
        $this->t('Link content'),
        $this->t('Examples: related articles, next/previous links'),
      ];
    }
  }

}

Members

Title Sort descending Modifiers Object type Summary Overrides
NodeFieldHooks::preConfiguredDescription public function Implements hook_field_ui_preconfigured_options_alter().
NodeFieldHooks::__construct public function
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

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