You are here

public function LightgalleryFormatter::settingsSummary in Lightgallery 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 FormatterBase::settingsSummary

File

src/Plugin/Field/FieldFormatter/LightgalleryFormatter.php, line 89

Class

LightgalleryFormatter
Light gallery formatter.

Namespace

Drupal\lightgallery\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  $image_styles = LightgalleryManager::getImageStyles();

  // Unset possible 'No defined styles' option.
  unset($image_styles['']);
  $thumb_image_style = new FieldThumbImageStyle();
  $lightgallery_image_style = new FieldLightgalleryImageStyle();
  $use_thumbnails = new FieldUseThumbs();
  $title_source = new FieldTitleSource();
  if (isset($image_styles[$this->settings[$lightgallery_image_style
    ->getGroup()
    ->getName()][$lightgallery_image_style
    ->getName()]])) {
    $summary[] = t('Lightgallery image style: @style', [
      '@style' => $image_styles[$this->settings[$lightgallery_image_style
        ->getGroup()
        ->getName()][$lightgallery_image_style
        ->getName()]],
    ]);
  }
  else {
    $summary[] = t('Lightgallery image style: Original image');
  }
  if (isset($image_styles[$this->settings[$thumb_image_style
    ->getGroup()
    ->getName()][$thumb_image_style
    ->getName()]])) {
    $summary[] = t('Thumbnail image style: @style', [
      '@style' => $image_styles[$this->settings[$thumb_image_style
        ->getGroup()
        ->getName()][$thumb_image_style
        ->getName()]],
    ]);
  }
  else {
    $summary[] = t('Thumbnail image style: Original image');
  }
  $summary[] = $this->settings[$use_thumbnails
    ->getGroup()
    ->getName()][$use_thumbnails
    ->getName()] ? t('Use thumbs in gallery: Yes') : t('Use thumbs in gallery: No');
  $summary[] = !empty($this->settings[$title_source
    ->getGroup()
    ->getName()][$title_source
    ->getName()]) ? t('Value used as title: @title', [
    '@title' => $this->settings[$title_source
      ->getGroup()
      ->getName()][$title_source
      ->getName()],
  ]) : t('Value used as title: none');
  return $summary;
}