You are here

public function InlineParagraphsWidget::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/InlineParagraphsWidget.php, line 171

Class

InlineParagraphsWidget
Plugin implementation of the 'entity_reference 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'),
  ]);
  switch ($this
    ->getSetting('edit_mode')) {
    case 'open':
    default:
      $edit_mode = $this
        ->t('Open');
      break;
    case 'closed':
      $edit_mode = $this
        ->t('Closed');
      break;
    case 'preview':
      $edit_mode = $this
        ->t('Preview');
      break;
  }
  switch ($this
    ->getSetting('add_mode')) {
    case 'select':
    default:
      $add_mode = $this
        ->t('Select list');
      break;
    case 'button':
      $add_mode = $this
        ->t('Buttons');
      break;
    case 'dropdown':
      $add_mode = $this
        ->t('Dropdown button');
      break;
  }
  $summary[] = $this
    ->t('Edit mode: @edit_mode', [
    '@edit_mode' => $edit_mode,
  ]);
  $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(),
    ]);
  }
  return $summary;
}