function FileItem::doGetUploadLocation
Same name in other branches
- 9 core/modules/file/src/Plugin/Field/FieldType/FileItem.php \Drupal\file\Plugin\Field\FieldType\FileItem::doGetUploadLocation()
- 8.9.x core/modules/file/src/Plugin/Field/FieldType/FileItem.php \Drupal\file\Plugin\Field\FieldType\FileItem::doGetUploadLocation()
- 11.x 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 - 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
File
-
core/
modules/ file/ src/ Plugin/ Field/ FieldType/ FileItem.php, line 331
Class
- FileItem
- Plugin implementation of the 'file' field type.
Namespace
Drupal\file\Plugin\Field\FieldTypeCode
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;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.