You are here

public static function FractionItem::propertyDefinitions in Fraction 8

Same name and namespace in other branches
  1. 2.x src/Plugin/Field/FieldType/FractionItem.php \Drupal\fraction\Plugin\Field\FieldType\FractionItem::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

src/Plugin/Field/FieldType/FractionItem.php, line 66

Class

FractionItem
Plugin implementation of the 'fraction' field type.

Namespace

Drupal\fraction\Plugin\Field\FieldType

Code

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
  $property_definitions['numerator'] = DataDefinition::create('integer')
    ->setLabel(t('Numerator value'));
  $property_definitions['denominator'] = DataDefinition::create('integer')
    ->setLabel(t('Denominator value'));
  $property_definitions['fraction'] = MapDataDefinition::create()
    ->setLabel(t('Fraction'))
    ->setDescription(t('A fraction object instance.'))
    ->setComputed(TRUE)
    ->setClass('\\Drupal\\fraction\\FractionProperty');
  $property_definitions['value'] = MapDataDefinition::create()
    ->setLabel(t('Fraction Decimal'))
    ->setDescription(t('Fraction decimal value.'))
    ->setComputed(TRUE)
    ->setClass('\\Drupal\\fraction\\FractionDecimalProperty');
  return $property_definitions;
}