RegenConfigFilesCommand.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace Opentalent\OtAdmin\Command;
  3. use Opentalent\OtAdmin\Controller\SiteController;
  4. use Opentalent\OtCore\Exception\NoSuchOrganizationException;
  5. use Symfony\Component\Console\Command\Command;
  6. use Symfony\Component\Console\Input\InputArgument;
  7. use Symfony\Component\Console\Input\InputInterface;
  8. use Symfony\Component\Console\Input\InputOption;
  9. use Symfony\Component\Console\Output\OutputInterface;
  10. use Symfony\Component\Console\Style\SymfonyStyle;
  11. use TYPO3\CMS\Core\Database\ConnectionPool;
  12. use TYPO3\CMS\Core\Utility\GeneralUtility;
  13. use TYPO3\CMS\Extbase\Object\ObjectManager;
  14. /**
  15. * This CLI command create or update the organization config file, and update the identifier field in ot_websites table
  16. * This is a light alternative to the update command, designed to be executed on a development env, just after
  17. * the databases cloning.
  18. *
  19. * @package Opentalent\OtAdmin\Command
  20. */
  21. class RegenConfigFilesCommand extends Command
  22. {
  23. public function __construct(
  24. private readonly SiteController $siteController
  25. ) {
  26. parent::__construct();
  27. }
  28. /**
  29. * -- This method is expected by Typo3, do not rename ou remove --
  30. *
  31. * Allows to configure the command.
  32. * Allows to add a description, a help text, and / or define arguments.
  33. *
  34. */
  35. protected function configure(): void
  36. {
  37. $this
  38. ->setName("ot:regen-config-files")
  39. ->setDescription("Recreate all of the website config files with the Db data");
  40. }
  41. /**
  42. * -- This method is expected by Typo3, do not rename ou remove --
  43. *
  44. * @param InputInterface $input
  45. * @param OutputInterface $output
  46. * @return int
  47. * @throws \Exception
  48. */
  49. protected function execute(InputInterface $input, OutputInterface $output): int
  50. {
  51. $io = new SymfonyStyle($input, $output);
  52. $this->siteController->regenConfigFilesAction();
  53. $io->success(sprintf("The config files were recreated"));
  54. return 0;
  55. }
  56. }