function FileUploadResource::getUploadLocation

Same name in other branches
  1. 9 core/modules/file/src/Plugin/rest/resource/FileUploadResource.php \Drupal\file\Plugin\rest\resource\FileUploadResource::getUploadLocation()
  2. 8.9.x core/modules/file/src/Plugin/rest/resource/FileUploadResource.php \Drupal\file\Plugin\rest\resource\FileUploadResource::getUploadLocation()

Determines the URI for a file field.

Parameters

array $settings: The array of field settings.

Return value

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

Deprecated

in drupal:10.3.0 and is removed from drupal:11.0.0. Use \Drupal\file\Upload\FileUploadLocationTrait::getUploadLocation() instead.

See also

https://www.drupal.org/node/3406099

File

core/modules/file/src/Plugin/rest/resource/FileUploadResource.php, line 396

Class

FileUploadResource
File upload resource.

Namespace

Drupal\file\Plugin\rest\resource

Code

protected function getUploadLocation(array $settings) {
    @\trigger_error(__METHOD__ . ' is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use \\Drupal\\file\\Upload\\FileUploadLocationTrait::getUploadLocation() instead. See https://www.drupal.org/node/3406099', E_USER_DEPRECATED);
    $destination = trim($settings['file_directory'], '/');
    // Replace tokens. As the tokens might contain HTML we convert it to plain
    // text.
    // @phpstan-ignore-next-line
    $destination = PlainTextOutput::renderFromHtml($this->token
        ->replace($destination, []));
    return $settings['uri_scheme'] . '://' . $destination;
}

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