You are here

public function PhotosUpload::path in Album Photos 8.5

Same name and namespace in other branches
  1. 8.4 src/PhotosUpload.php \Drupal\photos\PhotosUpload::path()
  2. 6.0.x src/PhotosUpload.php \Drupal\photos\PhotosUpload::path()

Temporary file path.

The image file path is now handled in the field settings. This is used if needed before the field settings are triggered.

Parameters

string $schemaType: A string with the URL alias to clean up.

Return value

string The cleaned URL alias.

Overrides PhotosUploadInterface::path

1 call to PhotosUpload::path()
PhotosUpload::unzip in src/PhotosUpload.php
Unzip archive of image files.

File

src/PhotosUpload.php, line 123

Class

PhotosUpload
Functions to help with uploading images to albums.

Namespace

Drupal\photos

Code

public function path($schemaType = 'default') {
  $path[] = 'photos';
  switch ($schemaType) {
    case 'private':
      $scheme = 'private';
      break;
    case 'public':
      $scheme = 'public';
      break;
    case 'default':
    default:
      $scheme = \Drupal::config('system.file')
        ->get('default_scheme');
      break;
  }
  $dirs = [];
  $finalPath = FALSE;

  // Prepare directory.
  foreach ($path as $folder) {
    $dirs[] = $folder;
    $finalPath = $scheme . '://' . implode('/', $dirs);
    if (!$this->fileSystem
      ->prepareDirectory($finalPath, FileSystemInterface::CREATE_DIRECTORY)) {
      return FALSE;
    }
  }
  if ($finalPath) {

    // Make sure the path does not end with a forward slash.
    $finalPath = rtrim($finalPath, '/');
  }
  return $finalPath;
}