setName("ot:site:delete") ->setDescription("Delete an organization website") ->setHelp("Call this method by giving it the organization's id in the Opentalent DB. By default, it proceed to a soft deletion, marking the records as deleted and renaming files: this kind of deletion can then be undone with the ot:site:undelete command. If the --hard option is passed, the records and files will be permanently deleted, with no possibility of undoing. A confirmation will be demanded.") ->addOption( 'hard', null, InputOption::VALUE_NONE, "Permanently delete the records and files. Use with caution." ) ->addOption( 'no-redirect', 'd', InputOption::VALUE_REQUIRED, "If set, the website's url won't be redirected to its parent's website" ) ->addOption( 'force', 'f', InputOption::VALUE_NONE, "Force the deletion of website directories, even if they are not empty (this has no effect without the --hard option)" ) ->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) { $org_id = $input->getArgument('organization-id'); $hard = $input->getOption('hard'); $force = $input->getOption('force'); $noRedirect = $input->getOption('no-redirect'); $io = new SymfonyStyle($input, $output); $rootUid = $this->siteController->deleteSiteAction($org_id, $hard, !$noRedirect, $force); if ($hard) { $io->success(sprintf("The website with root uid " . $rootUid . " has been permanently deleted")); } else { $io->success(sprintf("The website with root uid " . $rootUid . " has been soft-deleted. Use ot:site:undelete to restore it.")); } return 0; } }