You are here

public function ParagraphViewModeWidget::settingsSummary in Paragraph View Mode 2.x

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldWidget/ParagraphViewModeWidget.php \Drupal\paragraph_view_mode\Plugin\Field\FieldWidget\ParagraphViewModeWidget::settingsSummary()

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 StringTextfieldWidget::settingsSummary

File

src/Plugin/Field/FieldWidget/ParagraphViewModeWidget.php, line 118

Class

ParagraphViewModeWidget
Plugin implementation of the 'paragraph_view_mode' widget.

Namespace

Drupal\paragraph_view_mode\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $settings = $this
    ->getEnabledViewModes();
  if (empty($settings)) {
    $message = $this
      ->t('No view modes enabled, "@default" view mode will be used instead.', [
      '@default' => ViewModeInterface::DEFAULT,
    ]);
  }
  else {
    $message = $this
      ->t('Available view modes: @types', [
      '@types' => implode(', ', $settings),
    ]);
  }
  $summary[] = $message;
  return $summary;
}