You are here

protected function EntityReferenceBrowserWidget::summaryBase 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::summaryBase()

Provides base for settings summary shared by all EB widgets.

Return value

array A short summary of the widget settings.

2 calls to EntityReferenceBrowserWidget::summaryBase()
EntityReferenceBrowserWidget::settingsSummary in src/Plugin/Field/FieldWidget/EntityReferenceBrowserWidget.php
Returns a short summary for the current widget settings.
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 752

Class

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

Namespace

Drupal\entity_browser\Plugin\Field\FieldWidget

Code

protected function summaryBase() {
  $summary = [];
  $entity_browser_id = $this
    ->getSetting('entity_browser');
  if (empty($entity_browser_id)) {
    return [
      $this
        ->t('No entity browser selected.'),
    ];
  }
  else {
    if ($browser = $this->entityTypeManager
      ->getStorage('entity_browser')
      ->load($entity_browser_id)) {
      $summary[] = $this
        ->t('Entity browser: @browser', [
        '@browser' => $browser
          ->label(),
      ]);
    }
    else {
      $this->messenger
        ->addError($this
        ->t('Missing entity browser!'));
      return [
        $this
          ->t('Missing entity browser!'),
      ];
    }
  }
  $selection_mode = $this
    ->getSetting('selection_mode');
  $selection_mode_options = EntityBrowserElement::getSelectionModeOptions();
  if (isset($selection_mode_options[$selection_mode])) {
    $summary[] = $this
      ->t('Selection mode: @selection_mode', [
      '@selection_mode' => $selection_mode_options[$selection_mode],
    ]);
  }
  else {
    $summary[] = $this
      ->t('Undefined selection mode.');
  }
  return $summary;
}