You are here

public static function FileUrlItem::propertyDefinitions in File URL 8

Same name and namespace in other branches
  1. 2.0.x src/Plugin/Field/FieldType/FileUrlItem.php \Drupal\file_url\Plugin\Field\FieldType\FileUrlItem::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 FileItem::propertyDefinitions

See also

\Drupal\Core\Field\BaseFieldDefinition

File

src/Plugin/Field/FieldType/FileUrlItem.php, line 52

Class

FileUrlItem
Plugin implementation of the 'file_url' field type.

Namespace

Drupal\file_url\Plugin\Field\FieldType

Code

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
  $properties = parent::propertyDefinitions($field_definition);
  $target_id_definition = DataReferenceTargetDefinition::create('string')
    ->setLabel(new TranslatableMarkup('@label ID', [
    '@label' => 'file',
  ]));
  $target_id_definition
    ->setRequired(TRUE);
  $properties['target_id'] = $target_id_definition;
  return $properties;
}