You are here

public function EntityBlockWidget::settingsSummary in Entityblock 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/EntityBlockWidget.php, line 72
Contains \Drupal\entityblock\Plugin\Field\FieldWidget\EntityBlockWidget.

Class

EntityBlockWidget
Plugin implementation of the 'EntityBlock' widget.

Namespace

Drupal\entityblock\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = [];
  if ($this
    ->getSetting('view_modes')) {
    $view_modes = array_intersect_key($this
      ->getViewModes(), array_flip($this
      ->getSetting('view_modes')));
    $summary[] = $this
      ->t('View modes: %view_modes', array(
      '%view_modes' => implode(', ', $view_modes),
    ));
  }
  else {
    $summary[] = $this
      ->t('No view modes selected');
  }
  if ($this
    ->getSetting('force_enabled')) {
    $summary[] = $this
      ->t('Force "Display as block"');
  }
  if ($this
    ->getSetting('force_title')) {
    $summary[] = $this
      ->t('Force "Block title"');
  }
  return $summary;
}