You are here

protected function Select2EntityReferenceWidget::getSelectionSettings in Select 2 8

Build array of selection settings.

Return value

array Selection settings.

Throws

\Drupal\Component\Plugin\Exception\PluginNotFoundException

2 calls to Select2EntityReferenceWidget::getSelectionSettings()
Select2EntityReferenceWidget::formElement in src/Plugin/Field/FieldWidget/Select2EntityReferenceWidget.php
Returns the form for a single field widget.
Select2EntityReferenceWidget::getOptions in src/Plugin/Field/FieldWidget/Select2EntityReferenceWidget.php
Returns the array of options for the widget.

File

src/Plugin/Field/FieldWidget/Select2EntityReferenceWidget.php, line 198

Class

Select2EntityReferenceWidget
Plugin implementation of the 'select2' widget.

Namespace

Drupal\select2\Plugin\Field\FieldWidget

Code

protected function getSelectionSettings() {
  $label_field = $this->entityTypeManager
    ->getDefinition($this
    ->getFieldSetting('target_type'))
    ->getKey('label') ?: '_none';
  return [
    'match_operator' => $this
      ->getSetting('match_operator'),
    'match_limit' => $this
      ->getSetting('match_limit'),
    'sort' => [
      'field' => $label_field,
    ],
  ] + $this
    ->getFieldSetting('handler_settings');
}