You are here

public function DynamicEntityReferenceOptionsSelectWidget::supportsGroups in Dynamic Entity Reference 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/Field/FieldWidget/DynamicEntityReferenceOptionsSelectWidget.php \Drupal\dynamic_entity_reference\Plugin\Field\FieldWidget\DynamicEntityReferenceOptionsSelectWidget::supportsGroups()

Indicates whether the widgets support optgroups.

Return value

bool TRUE if the widget supports optgroups, FALSE otherwise.

Overrides OptionsSelectWidget::supportsGroups

File

src/Plugin/Field/FieldWidget/DynamicEntityReferenceOptionsSelectWidget.php, line 26

Class

DynamicEntityReferenceOptionsSelectWidget
Plugin implementation of the 'options_select' widget.

Namespace

Drupal\dynamic_entity_reference\Plugin\Field\FieldWidget

Code

public function supportsGroups() {
  $settings = $this
    ->getFieldSettings();
  $entity_type_id = current($settings['entity_type_ids']);

  // We only support groups when there is more than 1 target_bundle
  // available.
  return !empty($settings[$entity_type_id]['handler_settings']['target_bundles']) && count($settings[$entity_type_id]['handler_settings']['target_bundles']) > 1;
}