class DownloadController in Default Content Deploy 8
Returns responses for config module routes.
Hierarchy
- class \Drupal\default_content_deploy\Controller\DownloadController implements ContainerInjectionInterface
Expanded class hierarchy of DownloadController
File
- src/
Controller/ DownloadController.php, line 14
Namespace
Drupal\default_content_deploy\ControllerView source
class DownloadController implements ContainerInjectionInterface {
/**
* The DCD manager.
*
* @var \Drupal\default_content_deploy\DeployManager
*/
protected $deployManager;
/**
* The File system.
*
* @var \Drupal\Core\File\FileSystemInterface
*/
protected $fileSystem;
/**
* DownloadController constructor.
*
* @param \Drupal\default_content_deploy\DeployManager $deploy_manager
* The DCD manager.
* @param \Drupal\Core\File\FileSystemInterface $file_system
* The File system.
*/
public function __construct(DeployManager $deploy_manager, FileSystemInterface $file_system) {
$this->deployManager = $deploy_manager;
$this->fileSystem = $file_system;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static($container
->get('default_content_deploy.manager'), $container
->get('file_system'));
}
/**
* Return binary archive file for download.
*
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
*/
public function downloadCompressedContent() {
$this->deployManager
->compressContent();
$path = $this->fileSystem
->getTempDirectory() . '/dcd/content.tar.gz';
$headers = [
'Content-Type' => 'application/tar+gzip',
'Content-Description' => 'File Download',
'Content-Disposition' => 'attachment; filename=content.tar.gz',
];
return new BinaryFileResponse($path, 200, $headers);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DownloadController:: |
protected | property | The DCD manager. | |
DownloadController:: |
protected | property | The File system. | |
DownloadController:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
|
DownloadController:: |
public | function | Return binary archive file for download. | |
DownloadController:: |
public | function | DownloadController constructor. |