checkService = $checkService; $this->coreRequestBuilder = $coreRequestBuilder; $this->configService = $configService; $this->miscService = $miscService; } /** * */ protected function configure() { parent::configure(); $this->setName('social:reset') ->addOption('uninstall', '', InputOption::VALUE_NONE, 'full removing of the app') ->setDescription('Reset ALL data related to the Social App'); } /** * @param InputInterface $input * @param OutputInterface $output * * @throws Exception */ protected function execute(InputInterface $input, OutputInterface $output): int { $helper = $this->getHelper('question'); $output->writeln( 'Beware, this operation will delete all content from the Social App.' ); $output->writeln(''); $question = new ConfirmationQuestion( 'Do you confirm this operation? (y/N) ', false, '/^(y|Y)/i' ); if (!$helper->ask($input, $output, $question)) { return 0; } $question = new ConfirmationQuestion( 'Operation is destructive. Are you sure about this? (y/N) ', false, '/^(y|Y)/i' ); if (!$helper->ask($input, $output, $question)) { return 0; } if ($input->getOption('uninstall')) { try { $output->writeln(''); $output->write('Uninstalling Social App...'); $this->fullUninstall($output); $output->writeln('uninstalled'); } catch (Exception $e) { $output->writeln('' . $e->getMessage() . ''); } return 0; } $output->writeln(''); $output->write('flushing data... '); try { $this->coreRequestBuilder->emptyAll(); $output->writeln('done'); } catch (Exception $e) { $output->writeln('' . $e->getMessage() . ''); return 0; } $this->checkService->checkInstallationStatus(true); $output->writeln(''); $cloudAddress = $this->configService->getCloudUrl(); $question = new Question( 'Now is a good time to change the base address of your cloud: (' . $cloudAddress . ') ', $cloudAddress ); $newCloudAddress = $helper->ask($input, $output, $question); if ($newCloudAddress === $cloudAddress) { return 0; } $this->configService->setCloudUrl($newCloudAddress); $output->writeln(''); $output->writeln('New address: ' . $newCloudAddress . ''); return 0; } /** * @param OutputInterface $output */ private function fullUninstall(OutputInterface $output) { $this->coreRequestBuilder->uninstallSocialTables(); $this->coreRequestBuilder->uninstallFromMigrations(); $this->coreRequestBuilder->uninstallFromJobs(); $this->configService->unsetAppConfig(); } }