| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?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 creates an organization's website
- * by fetching its latest data from the Opentalent API
- *
- * @package Opentalent\OtAdmin\Command
- */
- class CreateOrganizationCommand 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:create")
- ->setDescription("Create an organization's website " .
- "by fetching its latest data from the Opentalent API")
- ->setHelp("Call this method by giving it the organization's id in the Opentalent DB.
- If no site exists, create it;
- If a site already exists, do nothing.")
- ->addArgument(
- 'organization_id',
- InputArgument::REQUIRED,
- "The organization's id in the opentalent DB"
- );
- }
- /**
- * -- 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
- */
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- // Make sure the _cli_ user is loaded
- // TYPO3\CMS\Core\Core\Bootstrap::initializeBackendAuthentication();
- $org_id = $input->getArgument('organization_id');
- $io = new SymfonyStyle($input, $output);
- $siteController = new SiteController();
- $rootUid = $siteController->createSiteAction($org_id);
- $io->success(sprintf("A new website has been created with root page uid=" . $rootUid));
- }
- }
|