Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / content_moderation / src / Plugin / Field / ModerationStateFieldItemList.php
index 8d48f26ae4787933204a0a085f47abebb034e22e..64c5ad849796d21b3623719d3bea82b97f40f5f1 100644 (file)
@@ -16,7 +16,6 @@ use Drupal\Core\TypedData\ComputedItemListTrait;
 class ModerationStateFieldItemList extends FieldItemList {
 
   use ComputedItemListTrait {
-    ensureComputedValue as traitEnsureComputedValue;
     get as traitGet;
   }
 
@@ -34,19 +33,6 @@ class ModerationStateFieldItemList extends FieldItemList {
     }
   }
 
-  /**
-   * {@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.
    *
@@ -88,7 +74,7 @@ class ModerationStateFieldItemList extends FieldItemList {
     $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
@@ -140,12 +126,12 @@ class ModerationStateFieldItemList extends FieldItemList {
    */
   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);
     }
   }