You are here

public function MediaSubFormManager::getTargetFieldDirectory in Media Bulk Upload 8

Get the target field settings for the media type.

Parameters

\Drupal\media\MediaTypeInterface $mediaType: Media Type.

Return value

string The directory location to store the files.

Overrides MediaSubFormManagerInterface::getTargetFieldDirectory

File

src/MediaSubFormManager.php, line 146

Class

MediaSubFormManager
Class MediaSubFormManager.

Namespace

Drupal\media_bulk_upload

Code

public function getTargetFieldDirectory(MediaTypeInterface $mediaType) {
  $targetFieldSettings = $this->mediaTypeManager
    ->getTargetFieldSettings($mediaType);
  $fileDirectory = trim($targetFieldSettings['file_directory'], '/');
  $fileDirectory = PlainTextOutput::renderFromHtml($this->token
    ->replace($fileDirectory));
  $targetDirectory = $targetFieldSettings['uri_scheme'] . '://' . $fileDirectory;
  $this->fileSystem
    ->prepareDirectory($targetDirectory, FileSystemInterface::CREATE_DIRECTORY);
  return $targetDirectory;
}