| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <?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;
- /**
- * This CLI command updates the organization's website if it exists, restores
- * it if it has been deleted, or creates it if it does not exist.
- * It also removes any redirections that may have been set on the domain.
- *
- * @package Opentalent\OtAdmin\Command
- */
- class JustMakeItWorkSiteCommand 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:just-make-it-work")
- ->setDescription("Forces the website to be updated / restored / created, according to its state")
- ->setHelp("Call this method by giving it the organization's id in the Opentalent DB.
- If no site exists, it will create it;
- If the site has been deleted, it will restore it;
- If a site already exists, it will update it.
- This command will also remove any redirections that may have been set on the domain.")
- ->addArgument(
- 'organization-id',
- InputArgument::REQUIRED,
- "The organization's id in the opentalent DB"
- )->addOption(
- 'dev',
- null,
- InputOption::VALUE_NONE,
- "Add this option to get url like 'http://host/subdomain' instead of 'http://subdomain.host'"
- );
- }
- /**
- * -- 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->justeMakeItWorkSiteAction($org_id);
- $io->success(sprintf("The website has been updated / restored / created (root page uid=" . $rootUid . ')'));
- return 0;
- }
- }
|