Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / system / tests / modules / entity_test / src / Plugin / Field / ComputedReferenceTestFieldItemList.php
diff --git a/web/core/modules/system/tests/modules/entity_test/src/Plugin/Field/ComputedReferenceTestFieldItemList.php b/web/core/modules/system/tests/modules/entity_test/src/Plugin/Field/ComputedReferenceTestFieldItemList.php
new file mode 100644 (file)
index 0000000..d28a014
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+namespace Drupal\entity_test\Plugin\Field;
+
+use Drupal\Core\Field\EntityReferenceFieldItemList;
+use Drupal\Core\TypedData\ComputedItemListTrait;
+
+/**
+ * A computed entity reference field item list.
+ */
+class ComputedReferenceTestFieldItemList extends EntityReferenceFieldItemList {
+
+  use ComputedItemListTrait;
+
+  /**
+   * Compute the list property from state.
+   */
+  protected function computeValue() {
+    foreach (\Drupal::state()->get('entity_test_reference_computed_target_ids', []) as $delta => $id) {
+      $this->list[$delta] = $this->createItem($delta, $id);
+    }
+  }
+
+}