You are here

public function YouTubeFormatter::settingsSummary in YouTube Field 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/YouTubeFormatter.php, line 109

Class

YouTubeFormatter
Plugin implementation of the 'youtube_video' formatter.

Namespace

Drupal\youtube\Plugin\Field\FieldFormatter

Code

public function settingsSummary() {
  $summary = [];
  $cp = '';
  $youtube_size = $this
    ->getSetting('youtube_size');
  $parameters = [
    $this
      ->getSetting('youtube_autoplay'),
    $this
      ->getSetting('youtube_mute'),
    $this
      ->getSetting('youtube_loop'),
    $this
      ->getSetting('youtube_controls'),
    $this
      ->getSetting('youtube_autohide'),
    $this
      ->getSetting('youtube_iv_load_policy'),
  ];
  foreach ($parameters as $parameter) {
    if ($parameter) {
      $cp = ', custom parameters';
      break;
    }
  }
  $summary[] = $this
    ->t('YouTube video: @youtube_size@cp', [
    '@youtube_size' => $youtube_size,
    '@cp' => $cp,
  ]);
  return $summary;
}