You are here

public function ModerationStateFieldItemList::setValue in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php \Drupal\content_moderation\Plugin\Field\ModerationStateFieldItemList::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.

bool $notify: (optional) Whether to notify the parent object of the change. Defaults to TRUE.

Overrides ComputedItemListTrait::setValue

File

core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php, line 129

Class

ModerationStateFieldItemList
A computed field that provides a content entity's moderation state.

Namespace

Drupal\content_moderation\Plugin\Field

Code

public function setValue($values, $notify = TRUE) {
  parent::setValue($values, $notify);
  $this->valueComputed = TRUE;

  // If the parent created a field item and if the parent should be notified
  // about the change (e.g. this is not initialized with the current value),
  // update the moderated entity.
  if (isset($this->list[0]) && $notify) {
    $this
      ->updateModeratedEntity($this->list[0]->value);
  }
}