FieldItemBase::setValue

public FieldItemBase::setValue($values, $notify = TRUE)

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

Parameters

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

Overrides Map::setValue

File

core/lib/Drupal/Core/Field/FieldItemBase.php, line 104

Class

FieldItemBase
An entity field item.

Namespace

Drupal\Core\Field

Code

public function setValue($values, $notify = TRUE) {
  // Treat the values as property value of the first property, if no array is
  // given.
  if (isset($values) && !is_array($values)) {
    $keys = array_keys($this->definition->getPropertyDefinitions());
    $values = array($keys[0] => $values);
  }
  parent::setValue($values, $notify);
}
doc_Drupal
2016-10-29 09:11:38
Comments
Leave a Comment

Please login to continue.