You are here

public function FieldItemBase::setValue in Zircon Profile 8

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

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

Parameters

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

Overrides Map::setValue

8 calls to FieldItemBase::setValue()
CreatedItem::applyDefaultValue in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php
Applies the default value.
EntityReferenceItem::setValue in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
Overrides \Drupal\Core\TypedData\TypedData::setValue().
FieldTestItem::postSave in core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php
Defines custom post-save behavior for field values.
FieldTestItem::preSave in core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/FieldTestItem.php
Defines custom presave behavior for field values.
LanguageItem::setValue in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php
Overrides \Drupal\Core\TypedData\TypedData::setValue().

... See full list

4 methods override FieldItemBase::setValue()
EntityReferenceItem::setValue in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
Overrides \Drupal\Core\TypedData\TypedData::setValue().
LanguageItem::setValue in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/LanguageItem.php
Overrides \Drupal\Core\TypedData\TypedData::setValue().
LinkItem::setValue in core/modules/link/src/Plugin/Field/FieldType/LinkItem.php
Overrides \Drupal\Core\TypedData\TypedData::setValue().
MapItem::setValue in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/MapItem.php
Overrides \Drupal\Core\TypedData\TypedData::setValue().

File

core/lib/Drupal/Core/Field/FieldItemBase.php, line 109
Contains \Drupal\Core\Field\FieldItemBase.

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);
}