public function ModerationStateFieldItemList::setValue in Drupal 8
Same name and namespace in other branches
- 9 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.
Overrides ComputedItemListTrait::setValue
File
- core/
modules/ content_moderation/ src/ Plugin/ Field/ ModerationStateFieldItemList.php, line 128
Class
- ModerationStateFieldItemList
- A computed field that provides a content entity's moderation state.
Namespace
Drupal\content_moderation\Plugin\FieldCode
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);
}
}