function InternalPropertyTestFieldItem::propertyDefinitions

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/InternalPropertyTestFieldItem.php \Drupal\entity_test\Plugin\Field\FieldType\InternalPropertyTestFieldItem::propertyDefinitions()
  2. 10 core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/InternalPropertyTestFieldItem.php \Drupal\entity_test\Plugin\Field\FieldType\InternalPropertyTestFieldItem::propertyDefinitions()
  3. 11.x core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/InternalPropertyTestFieldItem.php \Drupal\entity_test\Plugin\Field\FieldType\InternalPropertyTestFieldItem::propertyDefinitions()

Overrides StringItemBase::propertyDefinitions

File

core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/InternalPropertyTestFieldItem.php, line 28

Class

InternalPropertyTestFieldItem
Defines the 'Internal Property' entity test field type.

Namespace

Drupal\entity_test\Plugin\Field\FieldType

Code

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
    $properties = parent::propertyDefinitions($field_definition);
    // Add a computed property that is non-internal.
    $properties['non_internal_value'] = DataDefinition::create('string')->setLabel(new TranslatableMarkup('Computed string, non-internal property'))
        ->setComputed(TRUE)
        ->setClass(ComputedString::class)
        ->setInternal(FALSE);
    // Add a computed property that is internal.
    $properties['internal_value'] = DataDefinition::create('string')->setLabel(new TranslatableMarkup('Computed string, internal property'))
        ->setComputed(TRUE)
        ->setClass(ComputedString::class);
    return $properties;
}

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