function ModerationStateFieldItemList::computeValue

Same name in other branches
  1. 9 core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php \Drupal\content_moderation\Plugin\Field\ModerationStateFieldItemList::computeValue()
  2. 8.9.x core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php \Drupal\content_moderation\Plugin\Field\ModerationStateFieldItemList::computeValue()
  3. 11.x core/modules/content_moderation/src/Plugin/Field/ModerationStateFieldItemList.php \Drupal\content_moderation\Plugin\Field\ModerationStateFieldItemList::computeValue()

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\Field

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.