Exemplo n.º 1
0
 /**
  * @return ViewModel
  */
 public function modulesAction()
 {
     $installService = $this->getServiceLocator()->get('Install\\Service\\Install');
     $sessionProgress = new Container('progress_tracker');
     $sessionProgress->offsetSet('current_step', 'modules');
     $previousStep = $installService->checkPreviousStep();
     if (null !== $previousStep) {
         return $this->redirect()->toRoute('install/default', ['controller' => 'index', 'action' => $previousStep]);
     }
     $sessionProgress->offsetSet('modules', Install::TODO);
     $sessionForms = new Container('forms');
     $this->setProgress();
     if ($this->getRequest()->isPost()) {
         $modulesForm = new Modules();
         $modulesForm->setInputFilter(new ModulesInputFilter($this->getServiceLocator()));
         $modulesForm->setData($this->getRequest()->getPost());
         if ($modulesForm->isValid()) {
             $sessionForms->offsetSet('modulesForm', $modulesForm->getData());
             try {
                 $installService->hideModules($modulesForm);
                 $sessionProgress->offsetSet('modules', Install::DONE);
                 return $this->redirect()->toRoute('install/default', ['controller' => 'index', 'action' => 'modules-requirements']);
             } catch (\Exception $e) {
                 $modulesForm->get('Categories')->setMessages([$e->getMessage()]);
             }
         }
     } else {
         $modulesForm = new Modules();
         if (null !== $sessionForms->offsetGet('modulesForm')) {
             $modulesForm->setData($sessionForms->offsetGet('modulesForm'));
         }
     }
     return new ViewModel(['modulesForm' => $modulesForm]);
 }
Exemplo n.º 2
0
 /**
  * @param Modules $modulesForm
  */
 public function hideModules(Modules $modulesForm)
 {
     $modules = $modulesForm->getData();
     for ($i = 0; $i < count($modules); $i++) {
         $module = array_keys($modules)[$i];
         if (Install::UNCHECKED == array_values($modules)[$i]) {
             $this->replaceRowInFile('config/application.config.php', "'{$module}'", "//'{$module}'");
         } else {
             $this->replaceRowInFile('config/application.config.php', "//'{$module}'", "'{$module}',");
         }
     }
 }