diff options
Diffstat (limited to 'app/Http/RequestHandlers/ExportGedcomClient.php')
| -rw-r--r-- | app/Http/RequestHandlers/ExportGedcomClient.php | 27 |
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, '"') . '"'); |
