예제 #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $text = "";
     $configuration = new YamlConfiguration();
     if (false === $configuration->load()) {
         $configuration->setConfiguration($configuration->getDefaultConfiguration());
     }
     if ($input->getOption('enable-devmode')) {
         $configuration->setDevMode(true);
         $configuration->writeConfiguration();
         $text .= '<info>Dev mode has been changed to true</info>' . PHP_EOL;
     }
     if ($input->getOption('disable-devmode')) {
         $configuration->setDevMode(false);
         $configuration->writeConfiguration();
         $text .= '<info>Dev mode has been changed to false</info>' . PHP_EOL;
         $text .= 'Do not forget to empty all cache and purge XCache/APC caches manually.' . PHP_EOL;
     }
     if ($input->getOption('enable-install')) {
         $configuration->setInstall(true);
         $configuration->setDevMode(true);
         $configuration->writeConfiguration();
         $text .= '<info>Install mode has been changed to true</info>' . PHP_EOL;
     }
     if ($input->getOption('disable-install')) {
         $configuration->setInstall(false);
         $configuration->writeConfiguration();
         $text .= '<info>Install mode has been changed to false</info>' . PHP_EOL;
         $text .= 'Do not forget to empty all cache and purge XCache/APC caches manually.' . PHP_EOL;
     }
     if ($input->getOption('generate-htaccess')) {
         $text .= '<info>Generating .htaccess files…</info>' . PHP_EOL;
         // Simple deny access files
         $this->protectFolders(["/conf", "/src", "/samples", "/gen-src", "/files/fonts", "/files/private", "/bin", "/tests", "/cache", "/logs"], $text);
         $filePath = ROADIZ_ROOT . "/.htaccess";
         if (file_exists(ROADIZ_ROOT) && !file_exists($filePath)) {
             file_put_contents($filePath, $this->getMainHtaccessContent() . PHP_EOL);
             $text .= '    — ' . $filePath . PHP_EOL;
         } else {
             $text .= '    — Can’t write ' . $filePath . ", file already exists or folder is absent." . PHP_EOL;
         }
     }
     $output->writeln($text);
 }