GetSiteStatusCommand.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. namespace Opentalent\OtAdmin\Command;
  3. use Opentalent\OtAdmin\Controller\SiteController;
  4. use Symfony\Component\Console\Command\Command;
  5. use Symfony\Component\Console\Input\InputArgument;
  6. use Symfony\Component\Console\Input\InputInterface;
  7. use Symfony\Component\Console\Input\InputOption;
  8. use Symfony\Component\Console\Output\OutputInterface;
  9. use Symfony\Component\Console\Style\SymfonyStyle;
  10. use TYPO3\CMS\Core\Utility\GeneralUtility;
  11. use TYPO3\CMS\Extbase\Object\ObjectManager;
  12. /**
  13. * This CLI command returns a status code representing the current state of a given website
  14. *
  15. * @package Opentalent\OtAdmin\Command
  16. */
  17. class GetSiteStatusCommand extends Command
  18. {
  19. /**
  20. * -- This method is expected by Typo3, do not rename ou remove --
  21. *
  22. * Allows to configure the command.
  23. * Allows to add a description, a help text, and / or define arguments.
  24. *
  25. */
  26. protected function configure()
  27. {
  28. $this
  29. ->setName("ot:site:status")
  30. ->setDescription("Displays the current state of a given website")
  31. ->setHelp("This CLI command returns a status code representing the current state of a given website")
  32. ->addOption(
  33. 'full',
  34. null,
  35. InputOption::VALUE_NONE,
  36. "Performs a full scan"
  37. )
  38. ->addArgument(
  39. 'organization_id',
  40. InputArgument::REQUIRED,
  41. "The organization's id in the opentalent DB"
  42. );
  43. }
  44. /**
  45. * -- This method is expected by Typo3, do not rename ou remove --
  46. *
  47. * @param InputInterface $input
  48. * @param OutputInterface $output
  49. * @throws \Exception
  50. */
  51. protected function execute(InputInterface $input, OutputInterface $output)
  52. {
  53. $org_id = $input->getArgument('organization_id');
  54. $full = $input->getOption('full');
  55. $io = new SymfonyStyle($input, $output);
  56. $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
  57. $status = $siteController->getSiteStatusAction($org_id, $full);
  58. $io->success(sprintf("Status of the website: " . var_dump($status)));
  59. }
  60. }