You are here

public function SocialMediaLinksFieldDefaultFormatter::settingsSummary in Social Media Links Block and Field 8.2

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

File

modules/social_media_links_field/src/Plugin/Field/FieldFormatter/SocialMediaLinksFieldDefaultFormatter.php, line 144

Class

SocialMediaLinksFieldDefaultFormatter
Plugin implementation of the 'social_media_links_field_default' formatter.

Namespace

Drupal\social_media_links_field\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $config = $this
    ->getSettings();
  $summary = [];
  if (empty($config['appearance']['orientation'])) {
    $config['appearance']['orientation'] = 'h';
  }
  if (empty($config['appearance']['show_name'])) {
    $config['appearance']['show_name'] = 0;
  }
  $orientation = $config['appearance']['orientation'] == 'v' ? $this
    ->t('vertical') : $this
    ->t('horizontal');
  $summary[] = $this
    ->t('Orientation: @orientation', [
    '@orientation' => $orientation,
  ]);
  $show_name = isset($config['appearance']['show_name']) && $config['appearance']['show_name'] ? $this
    ->t('Yes') : $this
    ->t('No');
  $summary[] = $this
    ->t('Show name: @show_name', [
    '@show_name' => $show_name,
  ]);
  return $summary;
}