protected function ModerationStateFieldItemList::computeValue in Drupal 10
Same name and namespace in other branches
- 8 core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php \Drupal\content_moderation\Plugin\Field\ModerationStateFieldItemList::computeValue()
 - 9 core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php \Drupal\content_moderation\Plugin\Field\ModerationStateFieldItemList::computeValue()
 
Computes the values for an item list.
Overrides ComputedItemListTrait::computeValue
File
- core/
modules/ content_moderation/ src/ Plugin/ Field/ ModerationStateFieldItemList.php, line 25  
Class
- ModerationStateFieldItemList
 - A computed field that provides a content entity's moderation state.
 
Namespace
Drupal\content_moderation\Plugin\FieldCode
protected function computeValue() {
  $moderation_state = $this
    ->getModerationStateId();
  // Do not store NULL values, in the case where an entity does not have a
  // moderation workflow associated with it, we do not create list items for
  // the computed field.
  if ($moderation_state) {
    // An entity can only have a single moderation state.
    $this->list[0] = $this
      ->createItem(0, $moderation_state);
  }
}