/** * @Extra\Route( * "/export", * name="weaving_the_web_api_export_perspectives", * options={"expose"=true} * ) * @Extra\Method({"POST"}) */ public function exportAction() { $command = $this->exportPerspectiveCommand->getName(); if ($this->jobRepository->idleJobExistsForCommand($command)) { $message = $this->translator->trans('perspective.job.existing', [], 'perspective'); return new JsonResponse(['result' => $message, 'type' => 'error'], 429); } else { $token = $this->tokenStorage->getToken(); $job = $this->jobRepository->makeCommandJob($command, $token->getUser()); $this->entityManager->persist($job); $this->entityManager->flush(); $message = $this->translator->trans('perspective.job.submitted', [], 'perspective'); return new JsonResponse(['job' => ['entity' => 'job', 'id' => $job->getId(), 'Id' => $job->getId(), 'Status' => $this->jobRepository->getTranslatedStatusMessage($job), 'rlk_Output' => $job->getOutput(), 'Date' => $job->getCreatedAt()->format('Y-m-d H:i')], 'status' => $message, 'type' => 'success']); } }