function LinkItem::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

File

core/modules/link/src/Plugin/Field/FieldType/LinkItem.php, line 43

Class

LinkItem
Plugin implementation of the 'link' field type.

Namespace

Drupal\link\Plugin\Field\FieldType

Code

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
  $properties['uri'] = DataDefinition::create('uri')->setLabel(new TranslatableMarkup('URI'));
  $properties['title'] = DataDefinition::create('string')->setLabel(new TranslatableMarkup('Link text'));
  $properties['options'] = MapDataDefinition::create()->setLabel(new TranslatableMarkup('Options'));
  return $properties;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.