|
@@ -12,9 +12,9 @@ use App\Message\Command\Export;
|
|
|
use App\Service\ServiceIterator\ExporterIterator;
|
|
use App\Service\ServiceIterator\ExporterIterator;
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
|
use Exception;
|
|
use Exception;
|
|
|
|
|
+use Symfony\Component\HttpFoundation\JsonResponse;
|
|
|
use Symfony\Component\Messenger\MessageBusInterface;
|
|
use Symfony\Component\Messenger\MessageBusInterface;
|
|
|
use Symfony\Component\Security\Core\Security;
|
|
use Symfony\Component\Security\Core\Security;
|
|
|
-use Symfony\Component\HttpFoundation\Response;
|
|
|
|
|
|
|
|
|
|
class ExportRequestDataPersister implements ContextAwareDataPersisterInterface
|
|
class ExportRequestDataPersister implements ContextAwareDataPersisterInterface
|
|
|
{
|
|
{
|
|
@@ -33,10 +33,10 @@ class ExportRequestDataPersister implements ContextAwareDataPersisterInterface
|
|
|
/**
|
|
/**
|
|
|
* @param $exportRequest ExportRequest Une requête d'export
|
|
* @param $exportRequest ExportRequest Une requête d'export
|
|
|
* @param array $context
|
|
* @param array $context
|
|
|
- * @return Response
|
|
|
|
|
|
|
+ * @return JsonResponse
|
|
|
* @throws Exception
|
|
* @throws Exception
|
|
|
*/
|
|
*/
|
|
|
- public function persist($exportRequest, array $context = []): Response
|
|
|
|
|
|
|
+ public function persist($exportRequest, array $context = []): JsonResponse
|
|
|
{
|
|
{
|
|
|
/** @var Access $access */
|
|
/** @var Access $access */
|
|
|
$access = $this->security->getUser();
|
|
$access = $this->security->getUser();
|
|
@@ -60,14 +60,14 @@ class ExportRequestDataPersister implements ContextAwareDataPersisterInterface
|
|
|
if (!$exportRequest->isAsync()) {
|
|
if (!$exportRequest->isAsync()) {
|
|
|
$exportService = $this->handler->getExporterFor($exportRequest);
|
|
$exportService = $this->handler->getExporterFor($exportRequest);
|
|
|
$file = $exportService->export($exportRequest);
|
|
$file = $exportService->export($exportRequest);
|
|
|
- return new Response('File generated: ' . $file->getId(), 200);
|
|
|
|
|
|
|
+ return new JsonResponse(json_encode(['url' => 'https://my.download.url/' . $file->getId()], JSON_THROW_ON_ERROR), 200);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Send the export request to Messenger (@see App\Message\Handler\ExportHandler)
|
|
// Send the export request to Messenger (@see App\Message\Handler\ExportHandler)
|
|
|
$this->messageBus->dispatch(
|
|
$this->messageBus->dispatch(
|
|
|
new Export($exportRequest)
|
|
new Export($exportRequest)
|
|
|
);
|
|
);
|
|
|
- return new Response('Export request has been received (file id: ' . $file->getId() . ')', 200);
|
|
|
|
|
|
|
+ return new JsonResponse('{"message": "Export request has been received (file id: ' . $file->getId() . ')"', 200);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|