public static function IngredientItem::propertyDefinitions in Recipe 8.2
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 EntityReferenceItem::propertyDefinitions
See also
\Drupal\Core\Field\BaseFieldDefinition
File
- modules/
ingredient/ src/ Plugin/ Field/ FieldType/ IngredientItem.php, line 91
Class
- IngredientItem
- Plugin implementation of the 'ingredient' field type.
Namespace
Drupal\ingredient\Plugin\Field\FieldTypeCode
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
$properties = parent::propertyDefinitions($field_definition);
$properties['quantity'] = DataDefinition::create('')
->setLabel(t('Quantity'));
$properties['unit_key'] = DataDefinition::create('string')
->setLabel(t('Unit key'));
$properties['note'] = DataDefinition::create('string')
->setLabel(t('Note'));
return $properties;
}