Formatter Summary Service¶
Service identity¶
- Service ID:
name.formatter_summary - Interface:
Drupal\name\Service\NameFormatterSummaryInterface - Class:
Drupal\name\Service\NameFormatterSummaryService - Visibility:
@internal— builds manage-display summary text for thename_defaultformatter; not a supported extension point for custom modules.
Builds settings summary lines shown on the entity view display configuration UI for the Name field formatter.
Primary method¶
build(array $settings, FieldDefinitionInterface $fieldDefinition, string $markup, ?array $linkTargets): array¶
Parameters:
$settings— formatter plugin settings (format,list_format,link_target, and related keys).$fieldDefinition— the Name field definition (used for sample/example output).$markup— current markup mode (none,raw,simple,microdata,rdfa).$linkTargets— option labels from Link TargetgetTargets(), orNULLwhenlink_targetis empty (skips the link summary line).
Returns an array of translatable summary strings covering:
- Selected
name_format(with missing-format fallback text). - List format (
name_list_formator "Individually" when empty). - Markup mode label.
- Link target label when
$linkTargetsis provided. - Optional Example: line using sample values from
name.generatorand a temporarymarkupsetting onname.formatter(restored after formatting).
NameFormatter::settingsSummary() merges this output with preferred/alternative
lines from NameAdditionalPreferredTrait.
Dependencies¶
Registered in name.services.yml:
@entity_type.manager— loadsname_formatandname_list_formatentities.@name.generator— sample name values for the example line.@name.formatter— formats the example (briefly overridesmarkupsetting).@string_translation— summary string assembly.
Where it is used¶
Only Drupal\name\Plugin\Field\FieldFormatter\NameFormatter::settingsSummary().
It does not run at render time.
When to use¶
Do not inject name.formatter_summary from application code. Summary text
is owned by the formatter plugin and manage display configuration.