FileUriItem.php

Same filename in other branches
  1. 9 core/modules/file/src/Plugin/Field/FieldType/FileUriItem.php
  2. 8.9.x core/modules/file/src/Plugin/Field/FieldType/FileUriItem.php
  3. 11.x core/modules/file/src/Plugin/Field/FieldType/FileUriItem.php

Namespace

Drupal\file\Plugin\Field\FieldType

File

core/modules/file/src/Plugin/Field/FieldType/FileUriItem.php

View source
<?php

namespace Drupal\file\Plugin\Field\FieldType;

use Drupal\Core\Field\Attribute\FieldType;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Field\Plugin\Field\FieldType\UriItem;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\TypedData\DataDefinition;
use Drupal\file\ComputedFileUrl;

/**
 * File-specific plugin implementation of a URI item to provide a full URL.
 */
class FileUriItem extends UriItem {
    
    /**
     * {@inheritdoc}
     */
    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;
    }

}

Classes

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

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