src/V4/Action/Export/SyncPreConfiguredExportRequestAction.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\V4\Action\Export;
  3. use App\V4\Entity\PreconfiguredExport;
  4. use App\V4\Service\SyncPreConfiguredExportRunner\SyncPreConfiguredExportRunner;
  5. use Exception;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\JsonResponse;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. /**
  12.  * @Route("/api/v4/sync-preconfigured-export/{id}/export", name="sync_preconfigured_export_request", methods={"POST"})
  13.  */
  14. class SyncPreConfiguredExportRequestAction extends AbstractController
  15. {
  16.     /**
  17.      * @var SyncPreConfiguredExportRunner
  18.      */
  19.     private $exportRunner;
  20.     public function __construct(SyncPreConfiguredExportRunner $exportRunner)
  21.     {
  22.         $this->exportRunner $exportRunner;
  23.     }
  24.     /**
  25.      * @throws Exception
  26.      * @throws \Doctrine\DBAL\Driver\Exception
  27.      */
  28.     public function __invoke(
  29.         Request $request,
  30.         PreconfiguredExport $data
  31.     ): JsonResponse {
  32.         if ($data->isAsync()) {
  33.             return new JsonResponse(['message' => 'preconfigured_export_need_to_be_sync'], Response::HTTP_UNPROCESSABLE_ENTITY);
  34.         }
  35.         
  36.         //echo 'aaaa';
  37.         //exit;
  38.         
  39.         return $this->exportRunner->runExport($data$request->get('params') ?? []);
  40.     }
  41. }