You are here

public static function InventoryItem::propertyDefinitions in farmOS 2.x

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/core/inventory/src/Plugin/Field/FieldType/InventoryItem.php, line 50

Class

InventoryItem
Plugin implementation of the 'Inventory' field type.

Namespace

Drupal\farm_inventory\Plugin\Field\FieldType

Code

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
  $properties['measure'] = DataDefinition::create('string')
    ->setLabel(t('Measure of the inventory'));
  $properties['value'] = DataDefinition::create('string')
    ->setLabel(t('Value of the inventory'));
  $properties['units'] = DataDefinition::create('string')
    ->setLabel(t('Units of the inventory'));
  return $properties;
}