You are here

protected static function RangeItemBase::propertyDefinitionsByType in Range 8

Helper function. Returns field properties based on the given type.

Parameters

string $type: Range field data type. Either 'integer', 'float' or 'string'.

Return value

\Drupal\Core\TypedData\DataDefinitionInterface[] An array of property definitions of contained properties, keyed by property name.

3 calls to RangeItemBase::propertyDefinitionsByType()
RangeDecimalItem::propertyDefinitions in src/Plugin/Field/FieldType/RangeDecimalItem.php
Defines field item properties.
RangeFloatItem::propertyDefinitions in src/Plugin/Field/FieldType/RangeFloatItem.php
Defines field item properties.
RangeIntegerItem::propertyDefinitions in src/Plugin/Field/FieldType/RangeIntegerItem.php
Defines field item properties.

File

src/Plugin/Field/FieldType/RangeItemBase.php, line 97

Class

RangeItemBase
Base class for 'range' configurable field types.

Namespace

Drupal\range\Plugin\Field\FieldType

Code

protected static function propertyDefinitionsByType($type) {
  $properties = [];
  $properties['from'] = DataDefinition::create($type)
    ->setLabel(t('From value'))
    ->setRequired(TRUE);
  $properties['to'] = DataDefinition::create($type)
    ->setLabel(t('To value'))
    ->setRequired(TRUE);
  return $properties;
}