You are here

public function LanguageFormatter::settingsSummary in Custom Language field 8

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 StringFormatter::settingsSummary

File

src/Plugin/Field/FieldFormatter/LanguageFormatter.php, line 98

Class

LanguageFormatter
Plugin implementation of the 'language_field' formatter.

Namespace

Drupal\languagefield\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = parent::settingsSummary();
  $settings = $this
    ->getSettings()['format'];
  $options = LanguageItem::settingsOptions('formatter');
  if (empty($settings)) {
    $summary[] = $this
      ->t('** Not set **');
  }
  else {
    foreach ($settings as $value) {
      switch ($value) {
        case '0':

          // Option is not selected.
          break;
        default:
          $summary[] = isset($options[$value]) ? $options[$value] : '...';
          break;
      }
    }
  }
  return $summary;
}