You are here

public function FieldItemList::setValue in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Field/FieldItemList.php \Drupal\Core\Field\FieldItemList::setValue()

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

Parameters

array|null $values: An array of values of the field items, or NULL to unset the field.

Overrides ItemList::setValue

2 calls to FieldItemList::setValue()
FieldItemList::applyDefaultValue in core/lib/Drupal/Core/Field/FieldItemList.php
Applies the default value.
FieldItemList::generateSampleItems in core/lib/Drupal/Core/Field/FieldItemList.php

File

core/lib/Drupal/Core/Field/FieldItemList.php, line 117
Contains \Drupal\Core\Field\FieldItemList.

Class

FieldItemList
Represents an entity field; that is, a list of field item objects.

Namespace

Drupal\Core\Field

Code

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

  // Support passing in only the value of the first item, either as a litteral
  // (value of the first property) or as an array of properties.
  if (isset($values) && (!is_array($values) || !empty($values) && !is_numeric(current(array_keys($values))))) {
    $values = array(
      0 => $values,
    );
  }
  parent::setValue($values, $notify);
}