| 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\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 sets a new domain for the organization website
- *
- * @package Opentalent\OtAdmin\Command
- */
- class SetSiteDomainCommand extends Command
- {
- /**
- * -- 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()
- {
- $this
- ->setName("ot:site:setdomain")
- ->setDescription("Set a new domain for the organization website")
- ->setHelp("Set a new domain for the organization website. A new redirection will " .
- "be added from the existing domain to the new one. Use the --no-redirection option " .
- "to prevent this.")
- ->addArgument(
- 'organization-id',
- InputArgument::REQUIRED,
- "The organization's id in the opentalent DB"
- )
- ->addArgument(
- 'domain',
- InputArgument::REQUIRED,
- "The new domain to set up"
- )
- ->addOption(
- 'no-redirection',
- 'r',
- InputOption::VALUE_NONE,
- 'Use this option to prevent the creation of a redirection from the previous domain to the new one'
- );
- }
- /**
- * -- This method is expected by Typo3, do not rename ou remove --
- *
- * Executes the command for creating the new organization
- *
- * @param InputInterface $input
- * @param OutputInterface $output
- * @throws \Exception
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- $org_id = $input->getArgument('organization-id');
- $domain = $input->getArgument('domain');
- $redirect = ($input->getOption('no-redirection') == null);
- $io = new SymfonyStyle($input, $output);
- $siteController = GeneralUtility::makeInstance(ObjectManager::class)->get(SiteController::class);
- $rootUid = $siteController->setSiteCustomDomainAction($org_id, $domain, $redirect);
- $io->success(sprintf("The website with root uid " . $rootUid . " domain has been set to " . $domain));
- }
- }
|