ComputedReferenceTestFieldItemList.php in Drupal 9
File
core/modules/system/tests/modules/entity_test/src/Plugin/Field/ComputedReferenceTestFieldItemList.php
View source
<?php
namespace Drupal\entity_test\Plugin\Field;
use Drupal\Core\Field\EntityReferenceFieldItemList;
use Drupal\Core\TypedData\ComputedItemListTrait;
class ComputedReferenceTestFieldItemList extends EntityReferenceFieldItemList {
use ComputedItemListTrait;
protected function computeValue() {
foreach (\Drupal::state()
->get('entity_test_reference_computed_target_ids', []) as $delta => $id) {
$this->list[$delta] = $this
->createItem($delta, $id);
}
}
}