You are here

protected function AddMediaFormBase::getUploadLocation in Media Directories 8

Same name and namespace in other branches
  1. 2.x modules/media_directories_ui/src/Form/AddMediaFormBase.php \Drupal\media_directories_ui\Form\AddMediaFormBase::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.

2 calls to AddMediaFormBase::getUploadLocation()
FileUploadForm::buildInputElement in modules/media_directories_ui/src/Form/FileUploadForm.php
Inheriting classes need to build the desired input element.
MediaCombinedUploadForm::processInputValues in modules/media_directories_ui/src/Form/MediaCombinedUploadForm.php
Creates media items from source field input values.

File

modules/media_directories_ui/src/Form/AddMediaFormBase.php, line 199

Class

AddMediaFormBase
Class AddMediaFormBase.

Namespace

Drupal\media_directories_ui\Form

Code

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

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