You are here

public static function RadioactivityReferenceItem::propertyDefinitions in Radioactivity 4.0.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 EntityReferenceItem::propertyDefinitions

See also

\Drupal\Core\Field\BaseFieldDefinition

File

src/Plugin/Field/FieldType/RadioactivityReferenceItem.php, line 60

Class

RadioactivityReferenceItem
Plugin implementation of the Radioactivity Reference field type.

Namespace

Drupal\radioactivity\Plugin\Field\FieldType

Code

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
  $properties = parent::propertyDefinitions($field_definition);
  $properties['energy'] = DataDefinition::create('float')
    ->setLabel(new TranslatableMarkup('Energy level'))
    ->setDescription(new TranslatableMarkup('The radioactivity energy level'))
    ->setComputed(TRUE)
    ->setReadOnly(FALSE);
  return $properties;
}