You are here

public function ViewsReferenceItem::setValue in Views Reference Field 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Field/FieldType/ViewsReferenceItem.php \Drupal\viewsreference\Plugin\Field\FieldType\ViewsReferenceItem::setValue()

Overrides \Drupal\Core\TypedData\TypedData::setValue().

Parameters

array|null $values: An array of property values.

Overrides EntityReferenceItem::setValue

File

src/Plugin/Field/FieldType/ViewsReferenceItem.php, line 90

Class

ViewsReferenceItem
Defines the 'viewsreference' entity field type.

Namespace

Drupal\viewsreference\Plugin\Field\FieldType

Code

public function setValue($values, $notify = TRUE) {

  // Select widget has extra layer of items.
  if (isset($values['target_id']) && is_array($values['target_id'])) {
    $values['target_id'] = isset($values['target_id'][0]['target_id']) ? $values['target_id'][0]['target_id'] : NULL;
  }
  parent::setValue($values, FALSE);
}