src/Controller/Back/CronController.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Back;
  3. use SensioLabs\AnsiConverter\AnsiToHtmlConverter;
  4. use SensioLabs\AnsiConverter\Theme\SolarizedTheme;
  5. use Symfony\Bundle\FrameworkBundle\Console\Application;
  6. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  7. use Symfony\Component\Console\Input\ArrayInput;
  8. use Symfony\Component\Console\Output\BufferedOutput;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\HttpKernel\KernelInterface;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. /**
  13.  * @Route("/admin/cron")
  14.  */
  15. class CronController extends AbstractController
  16. {
  17.     /**
  18.      * @Route("", name="back_cron_index")
  19.      * @return Response
  20.      */
  21.     public function index(): Response
  22.     {
  23.         return $this->render('back/cron/index.html.twig', []);
  24.     }
  25.     /**
  26.      * @Route("/images/upload", name="back_cron_images_upload")
  27.      */
  28.     public function imageUpload(KernelInterface $kernel): Response
  29.     {
  30.         $application = new Application($kernel);
  31.         $application->setAutoExit(false);
  32.         $input = new ArrayInput([
  33.             'command' => 'images:upload'
  34.         ]);
  35.         // You can use NullOutput() if you don't need the output
  36.         $output = new BufferedOutput();
  37.         $application->run($input$output);
  38.         // return the output, don't use if you used NullOutput()
  39.         $theme = new SolarizedTheme();
  40.         $converter = new AnsiToHtmlConverter();
  41.         $content $output->fetch();
  42. //         return new Response($converter->convert($content));
  43.         return $this->json([
  44.             'content' => $converter->convert($content),
  45.         ]);
  46.     }
  47. }