You are here

public function TextareaWithSummaryAndCounterWidget::settingsSummary in Textfield Counter 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 TextareaWithSummaryWidget::settingsSummary

File

src/Plugin/Field/FieldWidget/TextareaWithSummaryAndCounterWidget.php, line 99

Class

TextareaWithSummaryAndCounterWidget
Plugin implementation of the 'text_textarea_with_summary_and_counter' widget.

Namespace

Drupal\textfield_counter\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = [];
  $this
    ->addPositionSummary($summary);
  $this
    ->addTextCountStatusMessageSummary($summary);
  $summary = array_merge($summary, parent::settingsSummary());
  $textarea_rows = $summary[0];
  unset($summary[0]);
  $summary_rows = $summary[1];
  unset($summary[1]);
  unset($summary[2]);
  if ($this
    ->getSetting('enable_summary')) {
    $summary['enable_summary'] = $this
      ->t('Enable summary field: %enabled', [
      '%enabled' => $this
        ->t('Yes'),
    ]);
    $summary['summary_open'] = $this
      ->t('Summary open: %open', [
      '%open' => $this
        ->getSetting('show_summary') ? $this
        ->t('Yes') : $this
        ->t('No'),
    ]);
    $summary['summary_rows'] = $summary_rows;
    $this
      ->addSummaryMaxlengthSummary($summary);
  }
  else {
    $summary['enable_summary'] = $this
      ->t('Enable summary field: %enabled', [
      '%enabled' => $this
        ->t('No'),
    ]);
  }
  $summary['num_rows'] = $textarea_rows;
  $this
    ->addMaxlengthSummary($summary);
  $this
    ->addJsSubmitPreventSummary($summary);
  $this
    ->addCountHtmlSummary($summary);
  return $summary;
}