addOption('sync', null, InputOption::VALUE_NONE, 'Create/remove the flag file so it matches the setting'); } protected function execute(InputInterface $input, OutputInterface $output): int { $setting = $this->ssrFlagService->isEnabledInSettings(); $flag = $this->ssrFlagService->isFlagSet(); $output->writeln('Setting vitec.ssr.enabled: ' . ($setting ? 'ON' : 'off')); $output->writeln('Flag ' . $this->ssrFlagService->getFlagPath() . ': ' . ($flag ? 'EXISTS (SSR routing active)' : 'absent (SPA as before)')); if ($setting === $flag) { $output->writeln('In sync.'); return Command::SUCCESS; } if (!$input->getOption('sync')) { $output->writeln('OUT OF SYNC - run with --sync (or just hit any page: the middleware repairs it).'); return Command::FAILURE; } $new = $this->ssrFlagService->sync(); $output->writeln('Synced: flag is now ' . ($new ? 'SET - SSR routing active.' : 'removed - SPA as before.') . ''); return Command::SUCCESS; } }