summaryrefslogtreecommitdiff
path: root/app/Http/RequestHandlers/ExportGedcomClient.php
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@gmail.com>2021-05-04 09:23:18 +0100
committerGreg Roach <fisharebest@gmail.com>2021-05-04 09:23:18 +0100
commit00c45d2300a5375d4779bf9dbe157d4ef56b9443 (patch)
tree227fee1ab9ef7d96d85af0d46e6453214bd5326c /app/Http/RequestHandlers/ExportGedcomClient.php
parent56afe05fa72eb037740c3a05c02828a7ba30f9a9 (diff)
downloadwebtrees-00c45d2300a5375d4779bf9dbe157d4ef56b9443.tar.gz
webtrees-00c45d2300a5375d4779bf9dbe157d4ef56b9443.tar.bz2
webtrees-00c45d2300a5375d4779bf9dbe157d4ef56b9443.zip
Revert "Move PSR17 factories to the registry"
This reverts commit 56afe05fa72eb037740c3a05c02828a7ba30f9a9.
Diffstat (limited to 'app/Http/RequestHandlers/ExportGedcomClient.php')
-rw-r--r--app/Http/RequestHandlers/ExportGedcomClient.php27
1 files changed, 20 insertions, 7 deletions
diff --git a/app/Http/RequestHandlers/ExportGedcomClient.php b/app/Http/RequestHandlers/ExportGedcomClient.php
index a11ec426e0..bdeae8562f 100644
--- a/app/Http/RequestHandlers/ExportGedcomClient.php
+++ b/app/Http/RequestHandlers/ExportGedcomClient.php
@@ -30,12 +30,15 @@ use League\Flysystem\Filesystem;
use League\Flysystem\FilesystemException;
use League\Flysystem\ZipArchive\FilesystemZipArchiveProvider;
use League\Flysystem\ZipArchive\ZipArchiveAdapter;
+use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
+use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Server\RequestHandlerInterface;
use RuntimeException;
use function addcslashes;
+use function app;
use function assert;
use function fclose;
use function fopen;
@@ -148,11 +151,16 @@ class ExportGedcomClient implements RequestHandlerInterface
}
// Use a stream, so that we do not have to load the entire file into memory.
- $http_stream = Registry::streamFactory()->createStreamFromFile($temp_zip_file);
- $filename = addcslashes($download_filename, '"') . '.zip';
+ $stream_factory = app(StreamFactoryInterface::class);
+ assert($stream_factory instanceof StreamFactoryInterface);
- return Registry::responseFactory()
- ->createResponse()
+ $http_stream = $stream_factory->createStreamFromFile($temp_zip_file);
+ $filename = addcslashes($download_filename, '"') . '.zip';
+
+ /** @var ResponseFactoryInterface $response_factory */
+ $response_factory = app(ResponseFactoryInterface::class);
+
+ return $response_factory->createResponse()
->withBody($http_stream)
->withHeader('Content-Type', 'application/zip')
->withHeader('Content-Disposition', 'attachment; filename="' . $filename . '"');
@@ -169,10 +177,15 @@ class ExportGedcomClient implements RequestHandlerInterface
$charset = $convert ? 'ISO-8859-1' : 'UTF-8';
- $http_stream = Registry::streamFactory()->createStreamFromResource($resource);
+ $stream_factory = app(StreamFactoryInterface::class);
+ assert($stream_factory instanceof StreamFactoryInterface);
+
+ $http_stream = $stream_factory->createStreamFromResource($resource);
+
+ /** @var ResponseFactoryInterface $response_factory */
+ $response_factory = app(ResponseFactoryInterface::class);
- return Registry::responseFactory()
- ->createResponse()
+ return $response_factory->createResponse()
->withBody($http_stream)
->withHeader('Content-Type', 'text/x-gedcom; charset=' . $charset)
->withHeader('Content-Disposition', 'attachment; filename="' . addcslashes($download_filename, '"') . '"');