You are here

protected function WebformManagedFileBase::getUploadLocation in Webform 6.x

Same name and namespace in other branches
  1. 8.5 src/Plugin/WebformElement/WebformManagedFileBase.php \Drupal\webform\Plugin\WebformElement\WebformManagedFileBase::getUploadLocation()

Get file upload location.

Parameters

array $element: An element.

\Drupal\webform\WebformInterface $webform: A webform.

Return value

string Upload location.

2 calls to WebformManagedFileBase::getUploadLocation()
WebformManagedFileBase::getTestValues in src/Plugin/WebformElement/WebformManagedFileBase.php
Get test values for an element.
WebformManagedFileBase::prepare in src/Plugin/WebformElement/WebformManagedFileBase.php
Prepare an element to be rendered within a webform.

File

src/Plugin/WebformElement/WebformManagedFileBase.php, line 641

Class

WebformManagedFileBase
Provides a base class webform 'managed_file' elements.

Namespace

Drupal\webform\Plugin\WebformElement

Code

protected function getUploadLocation(array $element, WebformInterface $webform) {
  if (empty($element['#upload_location'])) {
    $upload_location = $this
      ->getUriScheme($element) . '://webform/' . $webform
      ->id() . '/_sid_';
  }
  else {
    $upload_location = $element['#upload_location'];
  }

  // Make sure the upload location exists and is writable.
  $this->fileSystem
    ->prepareDirectory($upload_location, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
  return $upload_location;
}