Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

51 linhas
1.4KB

  1. <?php
  2. namespace Lc\SovBundle\Controller\Dashboard;
  3. use Lc\SovBundle\Controller\ControllerTrait;
  4. use Symfony\Bundle\FrameworkBundle\Console\Application;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\Console\Input\ArrayInput;
  7. use Symfony\Component\Console\Output\BufferedOutput;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. class CommandAdminController extends AbstractController
  12. {
  13. use ControllerTrait;
  14. /**
  15. * @Route("/admin/command/cache/clear", name="admin_command_cache_clear")
  16. */
  17. public function cacheClear(Request $request)
  18. {
  19. $this->doCommand('cache:clear');
  20. $this->addFlashTranslator('success', 'command.cacheClear');
  21. return $this->redirect($request->headers->get('referer'));
  22. }
  23. private function doCommand($command)
  24. {
  25. $kernel = $this->getKernel();
  26. $env = $kernel->getEnvironment();
  27. $application = new Application($kernel);
  28. $application->setAutoExit(false);
  29. $input = new ArrayInput(array(
  30. 'command' => $command,
  31. '--env' => $env
  32. ));
  33. $output = new BufferedOutput();
  34. $application->run($input, $output);
  35. $content = $output->fetch();
  36. //return new Response($content);
  37. }
  38. }