You are here

public function AmpSocialPostFormatter::settingsSummary in Accelerated Mobile Pages (AMP) 8.3

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

src/Plugin/Field/FieldFormatter/AmpSocialPostFormatter.php, line 144

Class

AmpSocialPostFormatter
Plugin implementation of the 'amp_social_post' formatter.

Namespace

Drupal\amp\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = parent::settingsSummary();
  $summary[] = $this
    ->t('Provider: :provider', [
    ':provider' => implode(', ', $this
      ->getSetting('provider')),
  ]);
  $settings = [
    'data-align-center' => $this
      ->t('Facebook centered'),
    'data-embed-as' => $this
      ->t('Facebook embed as'),
  ];
  foreach ($settings as $setting => $label) {
    $value = $this
      ->getSetting($setting);
    if (isset($value)) {
      $summary[] = $label . $this
        ->t(': :value', [
        ':value' => $value,
      ]);
    }
  }
  $summary[] = $this
    ->t('Twitter placeholder: :placeholder', [
    ':placeholder' => !empty($this
      ->getSetting('placeholder')) ? $this
      ->t('Yes') : $this
      ->t('No'),
  ]);
  $summary = $this
    ->addToSummary($summary);
  return [
    implode('; ', $summary),
  ];
}