Skip to content

Commit e95e4f4

Browse files
Remove Laminas dependencies
1 parent 7108ff8 commit e95e4f4

File tree

5 files changed

+19
-172
lines changed

5 files changed

+19
-172
lines changed

composer.json

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
"graylog2/gelf-php": "dev-master",
2323
"guzzlehttp/guzzle": "^7.2",
2424
"guzzlehttp/psr7": "^2.1",
25-
"laminas/laminas-diactoros": "^3.0",
26-
"laminas/laminas-httphandlerrunner": "^2.1",
2725
"league/commonmark": "^2.0",
2826
"league/container": "^4.2",
2927
"league/html-to-markdown": "^5.0",

composer.lock

+1-153
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/index.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
require $applicationDir . '/vendor/autoload.php';
66

77
use Fig\Http\Message\StatusCodeInterface;
8-
use Laminas\HttpHandlerRunner\Emitter\SapiEmitter;
98
use Monolog\Logger;
109
use Reconmap\ApiRouter;
1110
use Reconmap\Services\ApplicationConfig;
1211
use Reconmap\Services\ApplicationContainer;
1312
use Reconmap\Services\Logging\LoggingConfigurator;
13+
use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;
1414

1515
$configFilePath = $applicationDir . '/config.json';
1616
if (!file_exists($configFilePath) || !is_readable($configFilePath)) {
@@ -36,5 +36,8 @@
3636

3737
$response = $router->dispatch($request);
3838

39-
(new SapiEmitter)->emit($response);
39+
$httpFoundationFactory = new HttpFoundationFactory();
40+
$symfonyResponse = $httpFoundationFactory->createResponse($response);
41+
42+
$symfonyResponse->send();
4043

src/ApiRouter.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Reconmap;
44

5-
use Laminas\Diactoros\ResponseFactory;
5+
use GuzzleHttp\Psr7\HttpFactory;
66
use League\Container\Container;
77
use League\Route\RouteGroup;
88
use League\Route\Router;
@@ -64,7 +64,7 @@ class ApiRouter extends Router
6464

6565
public function mapRoutes(Container $container, ApplicationConfig $applicationConfig): void
6666
{
67-
$responseFactory = new ResponseFactory;
67+
$responseFactory = new HttpFactory();
6868

6969
$corsResponseDecorator = $container->get(CorsResponseDecorator::class);
7070
$logger = $container->get(Logger::class);

src/Controllers/System/ExportDataController.php

+11-13
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Reconmap\Controllers\System;
44

55
use GuzzleHttp\Psr7\Response;
6-
use Laminas\Diactoros\CallbackStream;
6+
use GuzzleHttp\Psr7\Utils;
77
use Psr\Http\Message\ResponseInterface;
88
use Psr\Http\Message\ServerRequestInterface;
99
use Reconmap\Controllers\Controller;
@@ -40,24 +40,22 @@ public function __invoke(ServerRequestInterface $request): ResponseInterface
4040

4141
$fileName = 'reconmap-' . $packageName . '-' . date('Ymd-His') . '.json';
4242

43-
$body = new CallbackStream(function () use ($entities) {
44-
$data = [];
43+
$data = [];
4544

46-
foreach (Exportables::List as $exportable) {
47-
$exportableKey = $exportable['key'];
48-
if (in_array($exportableKey, $entities)) {
49-
/** @var Exportable $exporter */
50-
$exporter = $this->container->get($exportable['className']);
51-
$data[$exportableKey] = $exporter->export();
52-
}
45+
foreach (Exportables::List as $exportable) {
46+
$exportableKey = $exportable['key'];
47+
if (in_array($exportableKey, $entities)) {
48+
/** @var Exportable $exporter */
49+
$exporter = $this->container->get($exportable['className']);
50+
$data[$exportableKey] = $exporter->export();
5351
}
52+
}
5453

55-
return json_encode($data);
56-
});
54+
$body = json_encode($data);
5755

5856
$response = new Response;
5957
return $response
60-
->withBody($body)
58+
->withBody(Utils::streamFor($body))
6159
->withHeader('Access-Control-Expose-Headers', 'Content-Disposition')
6260
->withHeader('Content-Disposition', 'attachment; filename="' . $fileName . '";')
6361
->withAddedHeader('Content-Type', 'application/json; charset=UTF-8');

0 commit comments

Comments
 (0)