You are here

public static function MeasurementItem::propertyDefinitions in Physical Fields 8

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

src/Plugin/Field/FieldType/MeasurementItem.php, line 30

Class

MeasurementItem
Plugin implementation of the 'physical_measurement' field type.

Namespace

Drupal\physical\Plugin\Field\FieldType

Code

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