class ComputedReferenceTestFieldItemList

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/modules/entity_test/src/Plugin/Field/ComputedReferenceTestFieldItemList.php \Drupal\entity_test\Plugin\Field\ComputedReferenceTestFieldItemList
  2. 10 core/modules/system/tests/modules/entity_test/src/Plugin/Field/ComputedReferenceTestFieldItemList.php \Drupal\entity_test\Plugin\Field\ComputedReferenceTestFieldItemList
  3. 8.9.x core/modules/system/tests/modules/entity_test/src/Plugin/Field/ComputedReferenceTestFieldItemList.php \Drupal\entity_test\Plugin\Field\ComputedReferenceTestFieldItemList

A computed entity reference field item list.

Hierarchy

Expanded class hierarchy of ComputedReferenceTestFieldItemList

1 file declares its use of ComputedReferenceTestFieldItemList
EntityTestComputedField.php in core/modules/system/tests/modules/entity_test/src/Entity/EntityTestComputedField.php

File

core/modules/system/tests/modules/entity_test/src/Plugin/Field/ComputedReferenceTestFieldItemList.php, line 11

Namespace

Drupal\entity_test\Plugin\Field
View source
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);
    }
  }

}

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