diff --git a/src/Bundle/ChillMainBundle/Export/Messenger/ExportRequestGenerationMessageHandler.php b/src/Bundle/ChillMainBundle/Export/Messenger/ExportRequestGenerationMessageHandler.php index 60079c982..ecb03af82 100644 --- a/src/Bundle/ChillMainBundle/Export/Messenger/ExportRequestGenerationMessageHandler.php +++ b/src/Bundle/ChillMainBundle/Export/Messenger/ExportRequestGenerationMessageHandler.php @@ -11,9 +11,12 @@ declare(strict_types=1); namespace Chill\MainBundle\Export\Messenger; +use Chill\DocStoreBundle\Entity\StoredObject; +use Chill\DocStoreBundle\Service\StoredObjectManagerInterface; use Chill\MainBundle\Export\ExportGenerator; use Chill\MainBundle\Repository\ExportGenerationRepository; use Chill\MainBundle\Repository\UserRepositoryInterface; +use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Messenger\Attribute\AsMessageHandler; use Symfony\Component\Messenger\Handler\MessageHandlerInterface; @@ -24,6 +27,8 @@ final readonly class ExportRequestGenerationMessageHandler implements MessageHan private ExportGenerationRepository $repository, private UserRepositoryInterface $userRepository, private ExportGenerator $exportGenerator, + private StoredObjectManagerInterface $storedObjectManager, + private EntityManagerInterface $entityManager, ) {} public function __invoke(ExportRequestGenerationMessage $exportRequestGenerationMessage) @@ -36,6 +41,10 @@ final readonly class ExportRequestGenerationMessageHandler implements MessageHan throw new \UnexpectedValueException('User not found'); } - $this->exportGenerator->generate($exportGeneration, $user); + $generated = $this->exportGenerator->generate($exportGeneration->getExportAlias(), $exportGeneration->getOptions(), $user); + $this->storedObjectManager->write($exportGeneration->getStoredObject(), $generated->content, $generated->contentType); + $exportGeneration->getStoredObject()->setStatus(StoredObject::STATUS_READY); + + $this->entityManager->flush(); } }