summaryrefslogtreecommitdiff
path: root/app/Http/RequestHandlers/ExportGedcomClient.php
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@gmail.com>2021-05-03 17:40:10 +0100
committerGreg Roach <fisharebest@gmail.com>2021-05-03 17:40:46 +0100
commit56afe05fa72eb037740c3a05c02828a7ba30f9a9 (patch)
tree86fa9a78fe37bc70a59b7893eea1e2b6555040d4 /app/Http/RequestHandlers/ExportGedcomClient.php
parentbd606c87b73e85df2cb4e759c1c3a6cf005799fb (diff)
downloadwebtrees-56afe05fa72eb037740c3a05c02828a7ba30f9a9.tar.gz
webtrees-56afe05fa72eb037740c3a05c02828a7ba30f9a9.tar.bz2
webtrees-56afe05fa72eb037740c3a05c02828a7ba30f9a9.zip
Move PSR17 factories to the registry
Diffstat (limited to 'app/Http/RequestHandlers/ExportGedcomClient.php')
-rw-r--r--app/Http/RequestHandlers/ExportGedcomClient.php27
1 files changed, 7 insertions, 20 deletions
diff --git a/app/Http/RequestHandlers/ExportGedcomClient.php b/app/Http/RequestHandlers/ExportGedcomClient.php
index bdeae8562f..a11ec426e0 100644
--- a/app/Http/RequestHandlers/ExportGedcomClient.php
+++ b/app/Http/RequestHandlers/ExportGedcomClient.php
@@ -30,15 +30,12 @@ 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;
@@ -151,16 +148,11 @@ class ExportGedcomClient implements RequestHandlerInterface
}
// Use a stream, so that we do not have to load the entire file into memory.
- $stream_factory = app(StreamFactoryInterface::class);
- assert($stream_factory instanceof StreamFactoryInterface);
+ $http_stream = Registry::streamFactory()->createStreamFromFile($temp_zip_file);
+ $filename = addcslashes($download_filename, '"') . '.zip';
- $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()
+ return Registry::responseFactory()
+ ->createResponse()
->withBody($http_stream)
->withHeader('Content-Type', 'application/zip')
->withHeader('Content-Disposition', 'attachment; filename="' . $filename . '"');
@@ -177,15 +169,10 @@ class ExportGedcomClient implements RequestHandlerInterface
$charset = $convert ? 'ISO-8859-1' : 'UTF-8';
- $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);
+ $http_stream = Registry::streamFactory()->createStreamFromResource($resource);
- return $response_factory->createResponse()
+ return Registry::responseFactory()
+ ->createResponse()
->withBody($http_stream)
->withHeader('Content-Type', 'text/x-gedcom; charset=' . $charset)
->withHeader('Content-Disposition', 'attachment; filename="' . addcslashes($download_filename, '"') . '"');