You are here

public function ParagraphsWidget::settingsSummary in Paragraphs 8

Returns a short summary for the current widget settings.

If an empty result is returned, a UI can still be provided to display a settings form in case the widget has configurable settings.

Return value

array A short summary of the widget settings.

Overrides WidgetBase::settingsSummary

File

src/Plugin/Field/FieldWidget/ParagraphsWidget.php, line 313

Class

ParagraphsWidget
Plugin implementation of the 'entity_reference_revisions paragraphs' widget.

Namespace

Drupal\paragraphs\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = array();
  $summary[] = $this
    ->t('Title: @title', [
    '@title' => $this
      ->getSetting('title'),
  ]);
  $summary[] = $this
    ->t('Plural title: @title_plural', [
    '@title_plural' => $this
      ->getSetting('title_plural'),
  ]);
  $edit_mode = $this
    ->getSettingOptions('edit_mode')[$this
    ->getSetting('edit_mode')];
  $closed_mode = $this
    ->getSettingOptions('closed_mode')[$this
    ->getSetting('closed_mode')];
  $add_mode = $this
    ->getSettingOptions('add_mode')[$this
    ->getSetting('add_mode')];
  $summary[] = $this
    ->t('Edit mode: @edit_mode', [
    '@edit_mode' => $edit_mode,
  ]);
  $summary[] = $this
    ->t('Closed mode: @closed_mode', [
    '@closed_mode' => $closed_mode,
  ]);
  if ($this
    ->getSetting('edit_mode') == 'closed') {
    $autocollapse = $this
      ->getSettingOptions('autocollapse')[$this
      ->getSetting('autocollapse')];
    $summary[] = $this
      ->t('Autocollapse: @autocollapse', [
      '@autocollapse' => $autocollapse,
    ]);
  }
  if (($this
    ->getSetting('edit_mode') == 'closed' || $this
    ->getSetting('edit_mode') == 'closed_expand_nested') && $this
    ->getSetting('closed_mode_threshold') > 0) {
    $summary[] = $this
      ->t('Closed mode threshold: @mode_limit', [
      '@mode_limit' => $this
        ->getSetting('closed_mode_threshold'),
    ]);
  }
  $summary[] = $this
    ->t('Add mode: @add_mode', [
    '@add_mode' => $add_mode,
  ]);
  $summary[] = $this
    ->t('Form display mode: @form_display_mode', [
    '@form_display_mode' => $this
      ->getSetting('form_display_mode'),
  ]);
  if ($this
    ->getDefaultParagraphTypeLabelName() !== NULL) {
    $summary[] = $this
      ->t('Default paragraph type: @default_paragraph_type', [
      '@default_paragraph_type' => $this
        ->getDefaultParagraphTypeLabelName(),
    ]);
  }
  $features_labels = array_intersect_key($this
    ->getSettingOptions('features'), array_filter($this
    ->getSetting('features')));
  if (!empty($features_labels)) {
    $summary[] = $this
      ->t('Features: @features', [
      '@features' => implode(', ', $features_labels),
    ]);
  }
  return $summary;
}