You are here

trait FlatteningOptionsTrait in Select2 Boxes 8

Trait FlatteningOptionsTrait.

@package Drupal\select2boxes

Hierarchy

2 files declare their use of FlatteningOptionsTrait
MultiSelect2BoxesAutocompleteWidget.php in src/Plugin/Field/FieldWidget/MultiSelect2BoxesAutocompleteWidget.php
SingleSelect2BoxesAutocompleteWidget.php in src/Plugin/Field/FieldWidget/SingleSelect2BoxesAutocompleteWidget.php

File

src/FlatteningOptionsTrait.php, line 10

Namespace

Drupal\select2boxes
View source
trait FlatteningOptionsTrait {

  /**
   * Flattening multi-bundled options to prevent possible collisions.
   *
   * @param array &$options
   *   Options array.
   */
  protected function flatteningOptions(array &$options) {

    // Fix for multi-bundled options.
    $flat_options = [];
    foreach ($options as $key => $option) {
      if (is_array($option)) {
        $flat_options += $option;
        unset($options[$key]);
      }
    }
    $options += $flat_options;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FlatteningOptionsTrait::flatteningOptions protected function Flattening multi-bundled options to prevent possible collisions.