class ComputedTestCacheableStringItemList

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

Item list class for computed cacheable string field.

Hierarchy

Expanded class hierarchy of ComputedTestCacheableStringItemList

1 file declares its use of ComputedTestCacheableStringItemList
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/ComputedTestCacheableStringItemList.php, line 12

Namespace

Drupal\entity_test\Plugin\Field
View source
class ComputedTestCacheableStringItemList extends FieldItemList {
  use ComputedItemListTrait;
  
  /**
   * {@inheritdoc}
   */
  protected function computeValue() {
    /** @var \Drupal\entity_test\Plugin\Field\FieldType\ComputedTestCacheableStringItem $item */
    $item = $this->createItem(0, 'computed test cacheable string field');
    $cacheability = (new CacheableMetadata())->setCacheContexts([
      'url.query_args:computed_test_cacheable_string_field',
    ])
      ->setCacheTags([
      'field:computed_test_cacheable_string_field',
    ])
      ->setCacheMaxAge(800);
    $item->get('value')
      ->addCacheableDependency($cacheability);
    $this->list[0] = $item;
  }

}

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