UpdateSiteCommand.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 update 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. * Executes the command for creating the new organization
  44. *
  45. * @param InputInterface $input
  46. * @param OutputInterface $output
  47. * @throws \Exception
  48. */
  49. protected function execute(InputInterface $input, OutputInterface $output)
  50. {
  51. $org_id = $input->getArgument('organization_id');
  52. $io = new SymfonyStyle($input, $output);
  53. $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
  54. $rootUid = $siteController->updateSiteConstantsAction($org_id);
  55. $io->success(sprintf("The website with root uid " . $rootUid . " has been updated"));
  56. }
  57. }