protected function getSelectedOptions(FieldItemListInterface $items, $delta = 0) {
    // We need to check against a flat list of options.
    $options = $this->getOptions($items->getEntity());

    $selected_options = [];
    foreach ($items as $item) {
      $value = $item->{$this->column};
      // Keep the value if it actually is in the list of options (needs to be
      // checked against the flat list).
      if (isset($options[$value])) {
        $selected_options[] = $value;
      }
    }

    return $selected_options;
  }
protected function getSelectedOptions(FieldItemListInterface $items, $delta = 0) {
    // We need to check against a flat list of options.
    $options = $this->getOptions($items->getEntity());

    $selected_options = [];
    foreach ($items as $item) {
      $value = $item->{$this->column};
      // Keep the value if it actually is in the list of options (needs to be
      // checked against the flat list).
      if (isset($options[$value])) {
        $selected_options[] = $value;
      }
    }

    return $selected_options;
  }
protected function getSelectedOptions ( FieldItemListInterface $ items , $ delta = 0 ) { // We need to check against a flat list of options. $ options = $ this -> getOptions ( $ items -> getEntity ( ) ) ; $ selected_options = [ ] ; foreach ( $ items as $ item ) { $ value = $ item -> { $ this -> column } ; // Keep the value if it actually is in the list of options (needs to be // checked against the flat list). if ( isset ( $ options [ $ value ] ) ) { $ selected_options [ ] = $ value ; } } return $ selected_options ; }
Determines selected options from the incoming field values.

@param \Drupal\Core\Field\FieldItemListInterface $items
The field values.
@param int $delta
(optional) The delta of the item to get options for. Defaults to 0.

@return array
The array of corresponding selected options.
Determines selected options from the incoming field values .