ComputedTestBundleFieldItemList.php

Same filename in other branches
  1. 10 core/modules/system/tests/modules/entity_test/src/Plugin/Field/ComputedTestBundleFieldItemList.php

Namespace

Drupal\entity_test\Plugin\Field

File

core/modules/system/tests/modules/entity_test/src/Plugin/Field/ComputedTestBundleFieldItemList.php

View source
<?php

declare (strict_types=1);
namespace Drupal\entity_test\Plugin\Field;

use Drupal\Core\TypedData\ComputedItemListTrait;
use Drupal\Core\Field\FieldItemList;

/**
 * A computed field item list for a bundle field.
 */
class ComputedTestBundleFieldItemList extends FieldItemList {
    use ComputedItemListTrait;
    
    /**
     * Compute the list property from state.
     */
    protected function computeValue() {
        foreach (\Drupal::state()->get('entity_test_comp_bund_fld_item_list_value', []) as $delta => $item) {
            $this->list[$delta] = $this->createItem($delta, $item);
        }
    }

}

Classes

Title Deprecated Summary
ComputedTestBundleFieldItemList A computed field item list for a bundle field.

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