class ComputedTestCacheableIntegerItemList

Same name in other branches
  1. 11.x core/modules/system/tests/modules/entity_test/src/Plugin/Field/ComputedTestCacheableIntegerItemList.php \Drupal\entity_test\Plugin\Field\ComputedTestCacheableIntegerItemList

Item list class for computed cacheable string field.

This class sets the cacheable metadata on the field item list directly.

Hierarchy

Expanded class hierarchy of ComputedTestCacheableIntegerItemList

See also

\Drupal\entity_test\Plugin\Field\ComputedTestCacheableStringItemList

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

Namespace

Drupal\entity_test\Plugin\Field
View source
class ComputedTestCacheableIntegerItemList extends FieldItemList implements CacheableDependencyInterface {
    use CacheableDependencyTrait, ComputedItemListTrait;
    
    /**
     * {@inheritdoc}
     */
    protected function computeValue() {
        $value = \Drupal::state()->get('entity_test_computed_integer_value', 0);
        $item = $this->createItem(0, $value);
        $cacheability = (new CacheableMetadata())->setCacheContexts([
            'url.query_args:computed_test_cacheable_integer_field',
        ])
            ->setCacheTags([
            'field:computed_test_cacheable_integer_field',
        ])
            ->setCacheMaxAge(31536000);
        $this->setCacheability($cacheability);
        $this->list[0] = $item;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
CacheableDependencyTrait::$cacheContexts protected property Cache contexts.
CacheableDependencyTrait::$cacheMaxAge protected property Cache max-age.
CacheableDependencyTrait::$cacheTags protected property Cache tags.
CacheableDependencyTrait::getCacheContexts public function 4
CacheableDependencyTrait::getCacheMaxAge public function 4
CacheableDependencyTrait::getCacheTags public function 4
CacheableDependencyTrait::setCacheability protected function Sets cacheability; useful for value object constructors.
ComputedTestCacheableIntegerItemList::computeValue protected function
DependencySerializationTrait::$_entityStorages protected property
DependencySerializationTrait::$_serviceIds protected property
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
FieldItemList::$langcode protected property The langcode of the field values held in the object.
FieldItemList::$list protected property Numerically indexed array of field items. Overrides ItemList::$list 1
FieldItemList::access public function Overrides AccessibleInterface::access 1
FieldItemList::applyDefaultValue public function Overrides TypedData::applyDefaultValue
FieldItemList::createItem protected function Overrides ItemList::createItem
FieldItemList::defaultAccess public function Overrides FieldItemListInterface::defaultAccess 3
FieldItemList::defaultValuesForm public function Overrides FieldItemListInterface::defaultValuesForm 2
FieldItemList::defaultValuesFormSubmit public function Overrides FieldItemListInterface::defaultValuesFormSubmit 2
FieldItemList::defaultValuesFormValidate public function Overrides FieldItemListInterface::defaultValuesFormValidate 2
FieldItemList::defaultValueWidget protected function Returns the widget object used in default value form.
FieldItemList::delegateMethod protected function Calls a method on each FieldItem.
FieldItemList::delete public function Overrides FieldItemListInterface::delete 2
FieldItemList::deleteRevision public function Overrides FieldItemListInterface::deleteRevision 1
FieldItemList::equals public function Overrides FieldItemListInterface::equals 2
FieldItemList::filterEmptyItems public function Overrides FieldItemListInterface::filterEmptyItems
FieldItemList::generateSampleItems public function Overrides FieldItemListInterface::generateSampleItems 1
FieldItemList::getConstraints public function Overrides TypedData::getConstraints 1
FieldItemList::getEntity public function Overrides FieldItemListInterface::getEntity 1
FieldItemList::getFieldDefinition public function Overrides FieldItemListInterface::getFieldDefinition
FieldItemList::getLangcode public function Overrides FieldItemListInterface::getLangcode
FieldItemList::getSetting public function Overrides FieldItemListInterface::getSetting
FieldItemList::getSettings public function Overrides FieldItemListInterface::getSettings
FieldItemList::hasAffectingChanges public function Overrides FieldItemListInterface::hasAffectingChanges 1
FieldItemList::postSave public function Overrides FieldItemListInterface::postSave 1
FieldItemList::preSave public function Overrides FieldItemListInterface::preSave 1
FieldItemList::processDefaultValue public static function Overrides FieldItemListInterface::processDefaultValue 2
FieldItemList::setLangcode public function Overrides FieldItemListInterface::setLangcode
FieldItemList::setValue public function Overrides ItemList::setValue
FieldItemList::view public function Overrides FieldItemListInterface::view
FieldItemList::__get public function Overrides FieldItemListInterface::__get
FieldItemList::__isset public function Overrides FieldItemListInterface::__isset
FieldItemList::__set public function Overrides FieldItemListInterface::__set
FieldItemList::__unset public function Overrides FieldItemListInterface::__unset
ItemList::appendItem public function Overrides ListInterface::appendItem
ItemList::count public function
ItemList::filter public function Overrides ListInterface::filter
ItemList::first public function Overrides ListInterface::first
ItemList::get public function Overrides ListInterface::get 2
ItemList::getItemDefinition public function Overrides ListInterface::getItemDefinition
ItemList::getIterator public function
ItemList::getString public function Overrides TypedData::getString
ItemList::getValue public function Overrides TypedData::getValue
ItemList::isEmpty public function Overrides ListInterface::isEmpty
ItemList::offsetExists public function 1
ItemList::offsetGet public function
ItemList::offsetSet public function
ItemList::offsetUnset public function
ItemList::onChange public function Overrides TraversableTypedDataInterface::onChange 1
ItemList::rekey protected function Renumbers the items in the list.
ItemList::removeItem public function Overrides ListInterface::removeItem
ItemList::set public function Overrides ListInterface::set
ItemList::__clone public function Magic method: Implements a deep clone.
StringTranslationTrait::$stringTranslation protected property The string translation service. 3
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
TypedData::$definition protected property The data definition. 1
TypedData::$name protected property The property name.
TypedData::$parent protected property The parent typed data object.
TypedData::createInstance public static function Overrides TypedDataInterface::createInstance
TypedData::getDataDefinition public function Overrides TypedDataInterface::getDataDefinition
TypedData::getName public function Overrides TypedDataInterface::getName
TypedData::getParent public function Overrides TypedDataInterface::getParent
TypedData::getPluginDefinition public function Overrides PluginInspectionInterface::getPluginDefinition
TypedData::getPluginId public function Overrides PluginInspectionInterface::getPluginId
TypedData::getPropertyPath public function Overrides TypedDataInterface::getPropertyPath
TypedData::getRoot public function Overrides TypedDataInterface::getRoot
TypedData::setContext public function Overrides TypedDataInterface::setContext
TypedData::validate public function Overrides TypedDataInterface::validate
TypedData::__construct public function Constructs a TypedData object given its definition and context. 4
TypedDataTrait::$typedDataManager protected property The typed data manager used for creating the data types.
TypedDataTrait::getTypedDataManager public function Gets the typed data manager. 2
TypedDataTrait::setTypedDataManager public function Sets the typed data manager. 2

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