From bf588535b2b42ca24601ba900dbd02a55fef9f39 Mon Sep 17 00:00:00 2001 From: tiennt Date: Sun, 3 Sep 2023 09:04:34 +0700 Subject: [PATCH] feat: dump --- src/Controller/ApiController.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Controller/ApiController.php b/src/Controller/ApiController.php index 797647bc4..d4961f2f8 100644 --- a/src/Controller/ApiController.php +++ b/src/Controller/ApiController.php @@ -23,12 +23,17 @@ use App\Service\Scheduler; use App\Util\UserAgentParser; use Composer\Pcre\Preg; +use Symfony\Bundle\FrameworkBundle\Console\Application; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\HttpFoundation\BinaryFileResponse; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Symfony\Component\Process\Exception\ProcessFailedException; +use Symfony\Component\Process\Process; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\Security\Core\Exception\AccessDeniedException; use Graze\DogStatsD\Client as StatsDClient; @@ -441,6 +446,15 @@ protected function receivePost(Request $request, string $url, string $urlRegex, $this->getEM()->flush(); + $process = new Process(['../bin/console', 'packagist:dump-v2']); + // Run the command + $process->run(); + + // Check if the command was successful + if (!$process->isSuccessful()) { + throw new ProcessFailedException($process); + } + return new JsonResponse(['status' => 'success', 'jobs' => $jobs, 'type' => $receiveType], 202); }