You are here

public function PackageDownloader::__construct in Ludwig 8

Constructs a new PackageDownloader object.

Parameters

\Drupal\Core\Archiver\ArchiverManager $archiver_manager: The archiver manager.

\Drupal\Core\File\FileSystemInterface $file_system: The file system.

\GuzzleHttp\ClientInterface $http_client: The HTTP client.

string $root: The app root.

File

src/PackageDownloader.php, line 71

Class

PackageDownloader
Download packages defined in ludwig.json files.

Namespace

Drupal\ludwig

Code

public function __construct(ArchiverManager $archiver_manager, FileSystemInterface $file_system, ClientInterface $http_client, $root) {
  $this->archiverManager = $archiver_manager;
  $this->fileSystem = $file_system;
  $this->httpClient = $http_client;
  $this->root = $root;
  $hash = substr(hash('sha256', Settings::getHashSalt()), 0, 8);
  $this->extractionDir = 'temporary://luwdig-extraction-' . $hash;
  if (!file_exists($this->extractionDir)) {
    mkdir($this->extractionDir);
  }
  $this->cacheDir = 'temporary://ludwig-cache-' . $hash;
  if (!file_exists($this->cacheDir)) {
    mkdir($this->cacheDir);
  }
}