UndeleteSiteCommand.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 undo the soft-deletion an existing organization's website
  12. *
  13. * @package Opentalent\OtAdmin\Command
  14. */
  15. class UndeleteSiteCommand extends Command
  16. {
  17. /**
  18. * -- This method is expected by Typo3, do not rename ou remove --
  19. *
  20. * Allows to configure the command.
  21. * Allows to add a description, a help text, and / or define arguments.
  22. *
  23. */
  24. protected function configure()
  25. {
  26. $this
  27. ->setName("ot:site:undelete")
  28. ->setDescription("Undo the soft-deletion of an organization website")
  29. ->setHelp("Call this method by giving it the organization's id in the Opentalent DB.
  30. If an organization website has been deleted with the ot:site:delete
  31. command and without the --hard option, you can undo the deletion with
  32. this command.")
  33. ->addArgument(
  34. 'organization_id',
  35. InputArgument::REQUIRED,
  36. "The organization's id in the opentalent DB"
  37. );
  38. }
  39. /**
  40. * -- This method is expected by Typo3, do not rename ou remove --
  41. *
  42. * Executes the command for creating the new organization
  43. *
  44. * @param InputInterface $input
  45. * @param OutputInterface $output
  46. * @throws \Exception
  47. */
  48. protected function execute(InputInterface $input, OutputInterface $output)
  49. {
  50. $org_id = $input->getArgument('organization_id');
  51. $io = new SymfonyStyle($input, $output);
  52. $siteController = new SiteController();
  53. $rootUid = $siteController->undeleteSiteAction($org_id);
  54. $io->success(sprintf("The website with root uid " . $rootUid . " has been restored"));
  55. }
  56. }