| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace Opentalent\OtAdmin\Command;
- use Opentalent\OtAdmin\Controller\SiteController;
- use Symfony\Component\Console\Command\Command;
- use Symfony\Component\Console\Input\InputArgument;
- use Symfony\Component\Console\Input\InputInterface;
- use Symfony\Component\Console\Input\InputOption;
- use Symfony\Component\Console\Output\OutputInterface;
- use Symfony\Component\Console\Style\SymfonyStyle;
- use TYPO3\CMS\Core\Utility\GeneralUtility;
- use TYPO3\CMS\Extbase\Object\ObjectManager;
- /**
- * This CLI command undoes the soft-deletion an existing organization's website and updates it
- *
- * @package Opentalent\OtAdmin\Command
- */
- class UndeleteSiteCommand extends Command
- {
- public function __construct(
- private readonly SiteController $siteController
- ) {
- parent::__construct();
- }
- /**
- * -- This method is expected by Typo3, do not rename ou remove --
- *
- * Allows to configure the command.
- * Allows to add a description, a help text, and / or define arguments.
- *
- */
- protected function configure(): void
- {
- $this
- ->setName("ot:site:undelete")
- ->setDescription("Undo the soft-deletion of an organization website and update it")
- ->setHelp("Call this method by giving it the organization's id in the Opentalent DB.
- If an organization website has been deleted with the ot:site:delete
- command and without the --hard option, you can undo the deletion with
- this command.")
- ->addArgument(
- 'organization-id',
- InputArgument::REQUIRED,
- "The organization's id in the opentalent DB"
- );
- }
- /**
- * -- This method is expected by Typo3, do not rename ou remove --
- *
- * @param InputInterface $input
- * @param OutputInterface $output
- * @return int
- * @throws \Exception
- */
- protected function execute(InputInterface $input, OutputInterface $output): int
- {
- $org_id = $input->getArgument('organization-id');
- $io = new SymfonyStyle($input, $output);
- $rootUid = $this->siteController->undeleteSiteAction($org_id);
- $this->siteController->updateSiteAction($org_id);
- $io->success(sprintf("The website with root uid " . $rootUid . " has been restored"));
- return 0;
- }
- }
|