| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?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\Output\OutputInterface;
- use Symfony\Component\Console\Style\SymfonyStyle;
- /**
- * This CLI command provoke the definitive deletion of all the pages
- * created by the users, leaving only the starting mandatory pages.
- *
- * /!\ Warning: this is a destructive operation
- *
- * @package Opentalent\OtAdmin\Command
- */
- class DeleteUserCreatedPagesCommand 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:delete-user-created-pages")
- ->setDescription("Delete all the pages created by the users, leaving only the starting mandatory pages.")
- ->setHelp("This CLI command provoke the definitive deletion of all the pages
- created by the users, leaving only the starting mandatory pages.
- /!\ Warning: this is a destructive operation.")
- ->addArgument(
- 'organization-id',
- InputArgument::OPTIONAL,
- "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);
- if (
- !$io->confirm("Are you sure you want to delete all the pages created " .
- "by the users? (organization id: " . $org_id . ")")
- ) {
- $io->error("Aborting.");
- return 1;
- }
- $rootUid = $this->siteController->deleteUserCreatedPagesAction($org_id);
- $io->success(sprintf("The website with root uid " . $rootUid . " had its user-created pages deleted."));
- return 0;
- }
- }
|