You are here

public static function RgbItem::propertyDefinitions in Examples for Developers 3.x

Same name and namespace in other branches
  1. 8 field_example/src/Plugin/Field/FieldType/RgbItem.php \Drupal\field_example\Plugin\Field\FieldType\RgbItem::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

File

modules/field_example/src/Plugin/Field/FieldType/RgbItem.php, line 49

Class

RgbItem
Plugin implementation of the 'field_example_rgb' field type.

Namespace

Drupal\field_example\Plugin\Field\FieldType

Code

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