You are here

public function EntitySelectWidget::settingsSummary in Commerce Core 8.2

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/EntitySelectWidget.php, line 75

Class

EntitySelectWidget
Plugin implementation of the 'commerce_entity_select' widget.

Namespace

Drupal\commerce\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = [];
  $hide_single_entity = $this
    ->getSetting('hide_single_entity');
  if ($this->fieldDefinition
    ->isRequired() && $hide_single_entity) {
    $summary[] = $this
      ->t("Hide if there's only one available entity");
  }
  $summary[] = $this
    ->t('Autocomplete threshold: @threshold entities.', [
    '@threshold' => $this
      ->getSetting('autocomplete_threshold'),
  ]);
  $summary[] = $this
    ->t('Autocomplete size: @size characters', [
    '@size' => $this
      ->getSetting('autocomplete_size'),
  ]);
  $placeholder = $this
    ->getSetting('autocomplete_placeholder');
  if (!empty($placeholder)) {
    $summary[] = $this
      ->t('Autocomplete placeholder: @placeholder', [
      '@placeholder' => $placeholder,
    ]);
  }
  else {
    $summary[] = $this
      ->t('No autocomplete placeholder');
  }
  return $summary;
}