You are here

protected static function FileItem::doGetUploadLocation in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/file/src/Plugin/Field/FieldType/FileItem.php \Drupal\file\Plugin\Field\FieldType\FileItem::doGetUploadLocation()

Determines the URI for a file field.

Parameters

array $settings: The array of field settings.

array $data: An array of token objects to pass to Token::replace().

Return value

string An unsanitized file directory URI with tokens replaced. The result of the token replacement is then converted to plain text and returned.

See also

\Drupal\Core\Utility\Token::replace()

3 calls to FileItem::doGetUploadLocation()
FileItem::generateSampleValue in core/modules/file/src/Plugin/Field/FieldType/FileItem.php
Generates placeholder field values.
FileItem::getUploadLocation in core/modules/file/src/Plugin/Field/FieldType/FileItem.php
Determines the URI for a file field.
ImageItem::generateSampleValue in core/modules/image/src/Plugin/Field/FieldType/ImageItem.php
Generates placeholder field values.

File

core/modules/file/src/Plugin/Field/FieldType/FileItem.php, line 284

Class

FileItem
Plugin implementation of the 'file' field type.

Namespace

Drupal\file\Plugin\Field\FieldType

Code

protected static function doGetUploadLocation(array $settings, $data = []) {
  $destination = trim($settings['file_directory'], '/');

  // Replace tokens. As the tokens might contain HTML we convert it to plain
  // text.
  $destination = PlainTextOutput::renderFromHtml(\Drupal::token()
    ->replace($destination, $data));
  return $settings['uri_scheme'] . '://' . $destination;
}