You are here

public static function FileUriItem::propertyDefinitions in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/file/src/Plugin/Field/FieldType/FileUriItem.php \Drupal\file\Plugin\Field\FieldType\FileUriItem::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 UriItem::propertyDefinitions

See also

\Drupal\Core\Field\BaseFieldDefinition

File

core/modules/file/src/Plugin/Field/FieldType/FileUriItem.php, line 27

Class

FileUriItem
File-specific plugin implementation of a URI item to provide a full URL.

Namespace

Drupal\file\Plugin\Field\FieldType

Code

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
  $properties = parent::propertyDefinitions($field_definition);
  $properties['url'] = DataDefinition::create('string')
    ->setLabel(t('Root-relative file URL'))
    ->setComputed(TRUE)
    ->setInternal(FALSE)
    ->setClass(ComputedFileUrl::class);
  return $properties;
}