You are here

public function BootstrapCarouselImageFormatter::settingsSummary in Bootstrap Carousel Image Formatter 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/BootstrapCarouselImageFormatter.php, line 161

Class

BootstrapCarouselImageFormatter
Plugin implementation of the 'bootstrap_image_carousel_formatter' formatter.

Namespace

Drupal\bootstrap_carousel_if\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  $image_styles = image_style_options(FALSE);

  // Unset possible 'No defined styles' option.
  unset($image_styles['']);
  $settings = $this
    ->getSettings();

  // Styles could be lost because of enabled/disabled modules that defines
  // their styles in code.
  $image_style_setting = $settings['image_style'];
  if (isset($image_styles[$image_style_setting])) {
    $summary[] = $this
      ->t('Bootstrap carousel : @style', [
      '@style' => $image_styles[$image_style_setting],
    ]);
  }
  else {
    $summary[] = $this
      ->t('Bootstrap carousel : Original image');
  }
  $summary[] = $this
    ->t('Interval @interval, @pause, @wrap, @indicators, @controls', [
    '@interval' => $settings['interval'],
    '@pause' => $settings['pause'] ? $this
      ->t('pause on hover') : $this
      ->t('no pause'),
    '@wrap' => $settings['wrap'] ? $this
      ->t('with wrap') : $this
      ->t('no wrap'),
    '@indicators' => $settings['indicators'] ? $this
      ->t('with indicators') : $this
      ->t('no indicators'),
    '@controls' => $settings['controls'] ? $this
      ->t('with controls') : $this
      ->t('no controls'),
  ]);
  return $summary;
}