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); }
protected function execute(InputInterface $input, OutputInterface $output) { $helper = $this->getHelper('question'); $this->entityManager = $this->getHelperSet()->get('em')->getEntityManager(); $text = ""; $question = new ConfirmationQuestion('Before installing Roadiz, did you create database schema? ' . PHP_EOL . 'If not execute: <info>bin/roadiz orm:schema-tool:create</info>' . PHP_EOL . '<question>Are you sure to perform installation?</question> : ', false); if ($input->getOption('no-interaction') || $helper->ask($input, $output, $question)) { /* * Create backend theme */ if (!$this->hasDefaultBackend()) { $theme = new Theme(); $theme->setAvailable(true)->setBackendTheme(true)->setClassName("Themes\\Rozier\\RozierApp"); $this->entityManager->persist($theme); $this->entityManager->flush(); $text .= '<info>Rozier back-end theme installed…</info>' . PHP_EOL; } else { $text .= '<error>A back-end theme is already installed.</error>' . PHP_EOL; } /** * Import default data */ $installRoot = ROADIZ_ROOT . "/themes/Install"; $yaml = new YamlConfiguration($installRoot . "/config.yml"); $yaml->load(); $data = $yaml->getConfiguration(); if (isset($data["importFiles"]['roles'])) { foreach ($data["importFiles"]['roles'] as $filename) { \RZ\Roadiz\CMS\Importers\RolesImporter::importJsonFile(file_get_contents($installRoot . "/" . $filename), $this->entityManager); $text .= ' — <info>Theme file “' . $installRoot . "/" . $filename . '” has been imported.</info>' . PHP_EOL; } } if (isset($data["importFiles"]['groups'])) { foreach ($data["importFiles"]['groups'] as $filename) { \RZ\Roadiz\CMS\Importers\GroupsImporter::importJsonFile(file_get_contents($installRoot . "/" . $filename), $this->entityManager); $text .= ' — <info>Theme file “' . $installRoot . "/" . $filename . '” has been imported..</info>' . PHP_EOL; } } if (isset($data["importFiles"]['settings'])) { foreach ($data["importFiles"]['settings'] as $filename) { \RZ\Roadiz\CMS\Importers\SettingsImporter::importJsonFile(file_get_contents($installRoot . "/" . $filename), $this->entityManager); $text .= ' — <info>Theme files “' . $installRoot . "/" . $filename . '” has been imported.</info>' . PHP_EOL; } } /* * Create default translation */ if (!$this->hasDefaultTranslation()) { $defaultTrans = new Translation(); $defaultTrans->setDefaultTranslation(true)->setLocale("en")->setName("Default translation"); $this->entityManager->persist($defaultTrans); $this->entityManager->flush(); $text .= '<info>Default translation installed…</info>' . PHP_EOL; } else { $text .= '<error>A default translation is already installed.</error>' . PHP_EOL; } /* * Disable install mode */ $configuration = new YamlConfiguration(); if (false === $configuration->load()) { $configuration->setConfiguration($configuration->getDefaultConfiguration()); } $configuration->setInstall(false); $configuration->writeConfiguration(); // Clear result cache $cacheDriver = $this->entityManager->getConfiguration()->getResultCacheImpl(); if ($cacheDriver !== null) { $cacheDriver->deleteAll(); } $text .= 'Install mode has been changed to false.' . PHP_EOL; } $output->writeln($text); }