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. /**
  11. * This CLI command update an existing organization's website
  12. * with the latest data from the Opentalent DB
  13. *
  14. * @package Opentalent\OtAdmin\Command
  15. */
  16. class UpdateSiteCommand extends Command
  17. {
  18. /**
  19. * -- This method is expected by Typo3, do not rename ou remove --
  20. *
  21. * Allows to configure the command.
  22. * Allows to add a description, a help text, and / or define arguments.
  23. *
  24. */
  25. protected function configure()
  26. {
  27. $this
  28. ->setName("ot:site:update")
  29. ->setDescription("Update an organization website")
  30. ->setHelp("This CLI command update an existing organization's website
  31. with the latest data from the Opentalent DB")
  32. ->addArgument(
  33. 'organization_id',
  34. InputArgument::REQUIRED,
  35. "The organization's id in the opentalent DB"
  36. );
  37. }
  38. /**
  39. * -- This method is expected by Typo3, do not rename ou remove --
  40. *
  41. * Executes the command for creating the new organization
  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 = new SiteController();
  52. $rootUid = $siteController->updateSiteConstantsAction($org_id);
  53. $io->success(sprintf("The website with root uid " . $rootUid . " has been updated"));
  54. }
  55. }