security->isGranted(SavedExportVoter::GENERATE, $export)) { throw new AccessDeniedHttpException('Not allowed to generate an export from this saved export'); } $user = $this->security->getUser(); if (!$user instanceof User) { throw new AccessDeniedHttpException('Only users can create exports'); } $exportGeneration = ExportGeneration::fromSavedExport($export, $this->clock->now()->add(new \DateInterval('P6M'))); $this->entityManager->persist($exportGeneration); $this->entityManager->flush(); $this->messageBus->dispatch(new ExportRequestGenerationMessage($exportGeneration, $user)); return new JsonResponse( $this->serializer->serialize($exportGeneration, 'json', ['groups' => ['read']]), json: true, ); } }