function ConfigController::downloadExport
Same name in other branches
- 8.9.x core/modules/config/src/Controller/ConfigController.php \Drupal\config\Controller\ConfigController::downloadExport()
- 10 core/modules/config/src/Controller/ConfigController.php \Drupal\config\Controller\ConfigController::downloadExport()
- 11.x core/modules/config/src/Controller/ConfigController.php \Drupal\config\Controller\ConfigController::downloadExport()
Downloads a tarball of the site configuration.
1 string reference to 'ConfigController::downloadExport'
- config.routing.yml in core/
modules/ config/ config.routing.yml - core/modules/config/config.routing.yml
File
-
core/
modules/ config/ src/ Controller/ ConfigController.php, line 130
Class
- ConfigController
- Returns responses for config module routes.
Namespace
Drupal\config\ControllerCode
public function downloadExport() {
try {
$this->fileSystem
->delete($this->fileSystem
->getTempDirectory() . '/config.tar.gz');
} catch (FileException $e) {
// Ignore failed deletes.
}
$archiver = new ArchiveTar($this->fileSystem
->getTempDirectory() . '/config.tar.gz', 'gz');
// Add all contents of the export storage to the archive.
foreach ($this->exportStorage
->listAll() as $name) {
$archiver->addString("{$name}.yml", Yaml::encode($this->exportStorage
->read($name)));
}
// Get all data from the remaining collections.
foreach ($this->exportStorage
->getAllCollectionNames() as $collection) {
$collection_storage = $this->exportStorage
->createCollection($collection);
foreach ($collection_storage->listAll() as $name) {
$archiver->addString(str_replace('.', '/', $collection) . "/{$name}.yml", Yaml::encode($collection_storage->read($name)));
}
}
$request = new Request([
'file' => 'config.tar.gz',
]);
return $this->fileDownloadController
->download($request, 'temporary');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.