You are here

public function FieldFormatterBase::settingsSummary in (Entity Reference) Field Formatters 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldFormatter/FieldFormatterBase.php \Drupal\field_formatter\Plugin\Field\FieldFormatter\FieldFormatterBase::settingsSummary()
  2. 3.x src/Plugin/Field/FieldFormatter/FieldFormatterBase.php \Drupal\field_formatter\Plugin\Field\FieldFormatter\FieldFormatterBase::settingsSummary()

Returns a short summary for the current formatter settings.

If an empty result is returned, a UI can still be provided to display a settings form in case the formatter has configurable settings.

Return value

string[] A short summary of the formatter settings.

Overrides FormatterBase::settingsSummary

2 calls to FieldFormatterBase::settingsSummary()
FieldFormatterFromViewDisplay::settingsSummary in src/Plugin/Field/FieldFormatter/FieldFormatterFromViewDisplay.php
Returns a short summary for the current formatter settings.
FieldFormatterWithInlineSettings::settingsSummary in src/Plugin/Field/FieldFormatter/FieldFormatterWithInlineSettings.php
Returns a short summary for the current formatter settings.
2 methods override FieldFormatterBase::settingsSummary()
FieldFormatterFromViewDisplay::settingsSummary in src/Plugin/Field/FieldFormatter/FieldFormatterFromViewDisplay.php
Returns a short summary for the current formatter settings.
FieldFormatterWithInlineSettings::settingsSummary in src/Plugin/Field/FieldFormatter/FieldFormatterWithInlineSettings.php
Returns a short summary for the current formatter settings.

File

src/Plugin/Field/FieldFormatter/FieldFormatterBase.php, line 70

Class

FieldFormatterBase
Base class for field formatters.

Namespace

Drupal\field_formatter\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = parent::settingsSummary();
  if ($field_name = $this
    ->getSetting('field_name')) {
    $summary[] = $this
      ->t('Field %field_name displayed.', [
      '%field_name' => $field_name,
    ]);
  }
  else {
    $summary[] = $this
      ->t('Field not configured.');
  }
  if ($this
    ->getSetting('link_to_entity')) {
    $entity_type = $this->entityTypeManager
      ->getDefinition($this->fieldDefinition
      ->getTargetEntityTypeId());
    $summary[] = $this
      ->t('Linked to this (parent) @entity_label', [
      '@entity_label' => $entity_type
        ->getLabel(),
    ]);
  }
  return $summary;
}