You are here

public function EntityReferenceBrowserWidget::settingsSummary in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldWidget/EntityReferenceBrowserWidget.php \Drupal\entity_browser\Plugin\Field\FieldWidget\EntityReferenceBrowserWidget::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 WidgetBase::settingsSummary

1 method overrides EntityReferenceBrowserWidget::settingsSummary()
FileBrowserWidget::settingsSummary in src/Plugin/Field/FieldWidget/FileBrowserWidget.php
Returns a short summary for the current widget settings.

File

src/Plugin/Field/FieldWidget/EntityReferenceBrowserWidget.php, line 308

Class

EntityReferenceBrowserWidget
Plugin implementation of the 'entity_reference' widget for entity browser.

Namespace

Drupal\entity_browser\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = $this
    ->summaryBase();
  $field_widget_display = $this
    ->getSetting('field_widget_display');
  if (!empty($field_widget_display)) {
    $pluginDefinition = $this->fieldDisplayManager
      ->getDefinition($field_widget_display);
    $field_widget_display_settings = $this
      ->getSetting('field_widget_display_settings');
    $field_widget_display_settings += [
      'entity_type' => $this->fieldDefinition
        ->getFieldStorageDefinition()
        ->getSetting('target_type'),
    ];
    $plugin = $this->fieldDisplayManager
      ->createInstance($field_widget_display, $field_widget_display_settings);
    $summary[] = $this
      ->t('Entity display: @name', [
      '@name' => $pluginDefinition['label'],
    ]);
    if ($field_widget_display == 'rendered_entity') {
      $view_mode_label = $plugin
        ->getViewModeLabel();
      $summary[] = $this
        ->t('View Mode: @view_mode', [
        '@view_mode' => $view_mode_label,
      ]);
    }
  }
  return $summary;
}