Skip to content

Additional Component Service

Service identity

  • Service ID: name.additional_component
  • Interface: Drupal\name\Service\AdditionalComponentInterface
  • Class: Drupal\name\Service\AdditionalComponentService
  • Visibility: @internal — use field/formatter settings and formatting APIs, not direct calls from custom modules unless you extend Name internals.

Resolves preferred and alternative name data from other entity fields when name format patterns reference those tokens (p, a, and related conditionals).

Primary method

getAdditionalComponent(FieldItemListInterface $items, mixed $key_value, mixed $sep_value): string

  • $key_value — field machine name on the parent entity, _self (entity label), or _self_property:property_name.
  • $sep_value — separator string when the source field has multiple values.
  • Returns rendered or label text suitable for injection into the component array before name.formatter runs.

Where it is used

  • Field typepreferred_field_reference and alternative_field_reference on NameItem (see Field storage settings).
  • Formatter plugin — display settings with the same keys for output.
  • User integrationUserHooks::userLoad() merges preferred/alternative values before formatting the account realname.