Пример #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);
 }
Пример #2
0
 /**
  * Install success screen.
  *
  * @param Symfony\Component\HttpFoundation\Request $request
  *
  * @return Symfony\Component\HttpFoundation\Response
  */
 public function doneAction(Request $request)
 {
     $doneForm = $this->buildDoneForm($request);
     if ($doneForm !== null) {
         $doneForm->handleRequest($request);
         if ($doneForm->isValid() && $doneForm->getData()['action'] == 'quit_install') {
             /*
              * Save informations
              */
             try {
                 $config = new YamlConfiguration();
                 if (false === $config->load()) {
                     $config->setConfiguration($config->getDefaultConfiguration());
                 }
                 $configuration = $config->getConfiguration();
                 $configuration['install'] = false;
                 $config->setConfiguration($configuration);
                 $config->writeConfiguration();
                 /*
                  * Close Session for security and temp translation
                  */
                 $this->getService('session')->invalidate();
                 $clearers = [new DoctrineCacheClearer($this->getService('em')), new TranslationsCacheClearer(), new RoutingCacheClearer(), new ConfigurationCacheClearer()];
                 foreach ($clearers as $clearer) {
                     $clearer->clear();
                 }
                 /*
                  * Force redirect to avoid resending form when refreshing page
                  */
                 return $this->redirect($this->generateUrl('installHomePage'));
             } catch (\Exception $e) {
                 $this->assignation['error'] = true;
                 $this->assignation['errorMessage'] = $e->getMessage() . PHP_EOL . $e->getTraceAsString();
             }
         }
         $this->assignation['doneForm'] = $doneForm->createView();
     }
     return $this->render('steps/done.html.twig', $this->assignation);
 }
Пример #3
0
 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);
 }
Пример #4
0
 /**
  * @param array $data
  *
  * @return void
  */
 public function saveInformations($data)
 {
     /*
      * Save settings
      */
     $set1 = $this->getSetting('site_name');
     $set1->setValue($data['site_name']);
     $set1->setType(NodeTypeField::STRING_T);
     $set2 = $this->getSetting('email_sender');
     $set2->setValue($data['email_sender']);
     $set2->setType(NodeTypeField::EMAIL_T);
     $set2 = $this->getSetting('email_sender_name');
     $set2->setValue($data['email_sender_name']);
     $set2->setType(NodeTypeField::STRING_T);
     $set2 = $this->getSetting('seo_description');
     $set2->setValue($data['seo_description']);
     $set2->setType(NodeTypeField::TEXT_T);
     $set2 = $this->getSetting('display_debug_panel');
     $set2->setValue(false);
     $set2->setType(NodeTypeField::BOOLEAN_T);
     $this->entityManager->flush();
     /*
      * Update timezone
      */
     if (!empty($data['timezone'])) {
         $conf = new YamlConfiguration();
         if (false === $conf->load()) {
             $conf->setConfiguration($conf->getDefaultConfiguration());
         }
         $config = $conf->getConfiguration();
         $config['timezone'] = $data['timezone'];
         $conf->setConfiguration($config);
         $conf->writeConfiguration();
     }
 }