You are here

function hackedProjectWebDownloader::get_destination in Hacked! 8.2

Returns a directory to save the downloaded project into.

4 calls to hackedProjectWebDownloader::get_destination()
hackedProjectWebDevDownloader::download in src/hackedProjectWebDevDownloader.php
Download the version of the project to compare.
hackedProjectWebDevDownloader::get_final_destination in src/hackedProjectWebDevDownloader.php
Returns the final destination of the unpacked project.
hackedProjectWebDownloader::get_final_destination in src/hackedProjectWebDownloader.php
Returns the final destination of the unpacked project.
hackedProjectWebFilesDownloader::download in src/hackedProjectWebFilesDownloader.php
Download the remote files to the local filesystem.

File

src/hackedProjectWebDownloader.php, line 52

Class

hackedProjectWebDownloader
Base class for downloading remote versions of projects.

Namespace

Drupal\hacked

Code

function get_destination() {
  $type = $this->project->project_type;
  $name = $this->project->name;
  $version = $this->project->existing_version;
  $dir = $this
    ->get_temp_directory() . "/{$type}/{$name}";

  // Build the destination folder tree if it doesn't already exists.
  if (!\Drupal::service('file_system')
    ->prepareDirectory($dir, FileSystemInterface::CREATE_DIRECTORY) && !mkdir($dir, 0775, TRUE)) {
    $message = $this
      ->t('Failed to create temp directory: %dir', [
      '%dir' => $dir,
    ]);
    \Drupal::logger('hacked')
      ->error($message);
    return FALSE;
  }
  return "{$dir}/{$version}";
}