UndeleteSiteCommand.php 2.3 KB

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