vendor/shopware/core/Framework/MessageQueue/ScheduledTask/Api/ScheduledTaskController.php line 38

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Framework\MessageQueue\ScheduledTask\Api;
  3. use Shopware\Core\Framework\MessageQueue\ScheduledTask\Scheduler\TaskScheduler;
  4. use Shopware\Core\Framework\Routing\Annotation\RouteScope;
  5. use Shopware\Core\Framework\Routing\Annotation\Since;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\HttpFoundation\JsonResponse;
  8. use Symfony\Component\Routing\Annotation\Route;
  9. /**
  10.  * @Route(defaults={"_routeScope"={"api"}})
  11.  */
  12. class ScheduledTaskController extends AbstractController
  13. {
  14.     /**
  15.      * @var TaskScheduler
  16.      */
  17.     private $taskScheduler;
  18.     /**
  19.      * @internal
  20.      */
  21.     public function __construct(TaskScheduler $taskScheduler)
  22.     {
  23.         $this->taskScheduler $taskScheduler;
  24.     }
  25.     /**
  26.      * @Since("6.0.0.0")
  27.      * @Route("/api/_action/scheduled-task/run", name="api.action.scheduled-task.run", methods={"POST"})
  28.      */
  29.     public function runScheduledTasks(): JsonResponse
  30.     {
  31.         $this->taskScheduler->queueScheduledTasks();
  32.         return $this->json(['message' => 'Success']);
  33.     }
  34.     /**
  35.      * @Since("6.0.0.0")
  36.      * @Route("/api/_action/scheduled-task/min-run-interval", name="api.action.scheduled-task.min-run-interval", methods={"GET"})
  37.      */
  38.     public function getMinRunInterval(): JsonResponse
  39.     {
  40.         return $this->json(['minRunInterval' => $this->taskScheduler->getMinRunInterval()]);
  41.     }
  42. }