class ModerationStateFieldItemList extends FieldItemList {
use ComputedItemListTrait {
- ensureComputedValue as traitEnsureComputedValue;
get as traitGet;
}
}
}
- /**
- * {@inheritdoc}
- */
- protected function ensureComputedValue() {
- // If the moderation state field is set to an empty value, always recompute
- // the state. Empty is not a valid moderation state value, when none is
- // present the default state is used.
- if (!isset($this->list[0]) || $this->list[0]->isEmpty()) {
- $this->valueComputed = FALSE;
- }
- $this->traitEnsureComputedValue();
- }
-
/**
* Gets the moderation state ID linked to a content entity revision.
*
$moderation_info = \Drupal::service('content_moderation.moderation_information');
$content_moderation_storage = \Drupal::entityTypeManager()->getStorage('content_moderation_state');
- $revisions = \Drupal::service('entity.query')->get('content_moderation_state')
+ $revisions = $content_moderation_storage->getQuery()
->condition('content_entity_type_id', $entity->getEntityTypeId())
->condition('content_entity_id', $entity->id())
// Ensure the correct revision is loaded in scenarios where a revision is
*/
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->valueComputed = TRUE;
$this->updateModeratedEntity($this->list[0]->value);
}
}