You are here

public static function ShapeItem::propertyDefinitions in Drupal 10

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

Defines field item properties.

Properties that are required to constitute a valid, non-empty item should be denoted with \Drupal\Core\TypedData\DataDefinition::setRequired().

Return value

\Drupal\Core\TypedData\DataDefinitionInterface[] An array of property definitions of contained properties, keyed by property name.

Overrides FieldItemInterface::propertyDefinitions

See also

\Drupal\Core\Field\BaseFieldDefinition

1 method overrides ShapeItem::propertyDefinitions()
ShapeItemRequired::propertyDefinitions in core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItemRequired.php
Defines field item properties.

File

core/modules/system/tests/modules/entity_test/src/Plugin/Field/FieldType/ShapeItem.php, line 32

Class

ShapeItem
Defines the 'shape' field type.

Namespace

Drupal\entity_test\Plugin\Field\FieldType

Code

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
  $properties['shape'] = DataDefinition::create('string')
    ->setLabel(t('Shape'));
  $properties['color'] = DataDefinition::create('string')
    ->setLabel(t('Color'));
  return $properties;
}