You are here

public function AmpFormTrait::addToSummary in Accelerated Mobile Pages (AMP) 8.3

Update the summary.

Update the field formatter summary for all settings provided by this trait.

4 calls to AmpFormTrait::addToSummary()
AmpImageCarousel::settingsSummary in src/Plugin/Field/FieldFormatter/AmpImageCarousel.php
Returns a short summary for the current formatter settings.
AmpImageFormatter::settingsSummary in src/Plugin/Field/FieldFormatter/AmpImageFormatter.php
Returns a short summary for the current formatter settings.
AmpSocialPostFormatter::settingsSummary in src/Plugin/Field/FieldFormatter/AmpSocialPostFormatter.php
Returns a short summary for the current formatter settings.
AmpVideoFormatter::settingsSummary in src/Plugin/Field/FieldFormatter/AmpVideoFormatter.php
Returns a short summary for the current formatter settings.

File

src/AmpFormTrait.php, line 36

Class

AmpFormTrait
AMP Form trait.

Namespace

Drupal\amp

Code

public function addToSummary($summary) {
  $settings = $this
    ->allSettings();
  foreach ($settings as $setting => $label) {
    $value = $this
      ->getSetting($setting);
    if (isset($value)) {
      if ($setting == 'width') {
        if ($this
          ->widthError($this
          ->getSetting('width'), $this
          ->getSetting('layout'))) {
          $value = $this
            ->t('INVALID!');
        }
      }
      if ($setting == 'height') {
        if ($this
          ->heightError($this
          ->getSetting('height'), $this
          ->getSetting('layout'))) {
          $value = $this
            ->t('INVALID!');
        }
      }
      if (!empty($value)) {
        $summary[] = $label . $this
          ->t(': :value', [
          ':value' => $value,
        ]);
      }
    }
  }
  return $summary;
}