You are here

protected function EntityReferenceDragDropWidget::viewModeOptions in Entity Reference Drag & Drop 8

Same name and namespace in other branches
  1. 2.x src/Plugin/Field/FieldWidget/EntityReferenceDragDropWidget.php \Drupal\entityreference_dragdrop\Plugin\Field\FieldWidget\EntityReferenceDragDropWidget::viewModeOptions()

Gets view mode options.

Return value

array

1 call to EntityReferenceDragDropWidget::viewModeOptions()
EntityReferenceDragDropWidget::settingsForm in src/Plugin/Field/FieldWidget/EntityReferenceDragDropWidget.php
Returns a form to configure settings for the widget.

File

src/Plugin/Field/FieldWidget/EntityReferenceDragDropWidget.php, line 324

Class

EntityReferenceDragDropWidget
Plugin implementation of the 'entityreference_dragdrop' widget.

Namespace

Drupal\entityreference_dragdrop\Plugin\Field\FieldWidget

Code

protected function viewModeOptions() {
  $target_type_id = $this->fieldDefinition
    ->getFieldStorageDefinition()
    ->getSetting('target_type');
  $view_modes = $this->entityDisplayRepository
    ->getViewModes($target_type_id);
  $options = [
    static::VIEW_MODE_TITLE => $this
      ->t('Title'),
  ];
  foreach ($view_modes as $view_mode) {
    $options[$view_mode['id']] = $view_mode['label'];
  }
  return $options;
}