You are here

public function MediaLibraryWidget::settingsSummary in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/media_library/src/Plugin/Field/FieldWidget/MediaLibraryWidget.php \Drupal\media_library\Plugin\Field\FieldWidget\MediaLibraryWidget::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

File

core/modules/media_library/src/Plugin/Field/FieldWidget/MediaLibraryWidget.php, line 270

Class

MediaLibraryWidget
Plugin implementation of the 'media_library_widget' widget.

Namespace

Drupal\media_library\Plugin\Field\FieldWidget

Code

public function settingsSummary() {
  $summary = [];
  $media_type_labels = [];
  $media_types = $this->entityTypeManager
    ->getStorage('media_type')
    ->loadMultiple($this
    ->getAllowedMediaTypeIdsSorted());
  if (count($media_types) !== 1) {
    foreach ($media_types as $media_type) {
      $media_type_labels[] = $media_type
        ->label();
    }
    $summary[] = t('Tab order: @order', [
      '@order' => implode(', ', $media_type_labels),
    ]);
  }
  return $summary;
}