UpdateSiteCommand.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 updates an existing organization's website
  14. * with the latest data from the Opentalent DB
  15. *
  16. * @package Opentalent\OtAdmin\Command
  17. */
  18. class UpdateSiteCommand extends Command
  19. {
  20. /**
  21. * -- This method is expected by Typo3, do not rename ou remove --
  22. *
  23. * Allows to configure the command.
  24. * Allows to add a description, a help text, and / or define arguments.
  25. *
  26. */
  27. protected function configure()
  28. {
  29. $this
  30. ->setName("ot:site:update")
  31. ->setDescription("Update an organization website")
  32. ->setHelp("This CLI command update an existing organization's website
  33. with the latest data from the Opentalent DB")
  34. ->addArgument(
  35. 'organization-id',
  36. InputArgument::REQUIRED,
  37. "The organization's id in the opentalent DB"
  38. );
  39. }
  40. /**
  41. * -- This method is expected by Typo3, do not rename ou remove --
  42. *
  43. * @param InputInterface $input
  44. * @param OutputInterface $output
  45. * @throws \Exception
  46. */
  47. protected function execute(InputInterface $input, OutputInterface $output)
  48. {
  49. $org_id = $input->getArgument('organization-id');
  50. $io = new SymfonyStyle($input, $output);
  51. $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
  52. $rootUid = $siteController->updateSiteConstantsAction($org_id);
  53. $io->success(sprintf("The website with root uid " . $rootUid . " has been updated"));
  54. }
  55. }