You are here

public function StaticDownloadController::download in Tome 8

Downloads a tarball of the static build.

1 string reference to 'StaticDownloadController::download'
tome_static.routing.yml in modules/tome_static/tome_static.routing.yml
modules/tome_static/tome_static.routing.yml

File

modules/tome_static/src/Controller/StaticDownloadController.php, line 93

Class

StaticDownloadController
Contains routes related to Tome Static.

Namespace

Drupal\tome_static\Controller

Code

public function download() {
  $path = $this->fileSystem
    ->getTempDirectory() . '/tome_static_export.tar.gz';
  $static_directory = $this->static
    ->getStaticDirectory();
  $this->fileSystem
    ->delete($path);
  $archiver = new ArchiveTar($path, 'gz');
  $archiver
    ->addModify([
    $static_directory,
  ], '', $static_directory);
  $response = new BinaryFileResponse($path, 200, [], FALSE);
  $response
    ->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, basename($path));
  return $response;
}