function StringFormatter::settingsSummary

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter::settingsSummary()
  2. 10 core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter::settingsSummary()
  3. 9 core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter::settingsSummary()
  4. 8.9.x core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php \Drupal\Core\Field\Plugin\Field\FieldFormatter\StringFormatter::settingsSummary()

Overrides FormatterBase::settingsSummary

1 call to StringFormatter::settingsSummary()
LanguageFormatter::settingsSummary in core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php
1 method overrides StringFormatter::settingsSummary()
LanguageFormatter::settingsSummary in core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/LanguageFormatter.php

File

core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php, line 119

Class

StringFormatter
Plugin implementation of the 'string' formatter.

Namespace

Drupal\Core\Field\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  if ($this->getSetting('link_to_entity')) {
    $label = $this->entityTypeManager
      ->getDefinition($this->fieldDefinition
      ->getTargetEntityTypeId())
      ->getSingularLabel();
    $variables = [
      '@entity_type' => $label,
    ];
    $link_rel = $this->getSetting('link_rel');
    $summary[] = match ($link_rel) {  'canonical' => $this->t('Link to view the @entity_type', $variables),
      'edit-form' => $this->t('Link to edit the @entity_type', $variables),
      default => $this->t('Linked to @link_template', [
        '@link_template' => $link_rel,
      ]),
    
    };
  }
  return $summary;
}

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