Пример #1
0
 public function install_modules()
 {
     $this->config->addPackage('unknown', ASSETSPATH);
     $class_name = $this->config->get('unknown', 'package', 'main.class_name');
     $name_lowercase = strtolower($class_name);
     $modules = ['foolframe' => ['context' => '\\Foolz\\FoolFrame\\Model\\Context', 'namespace' => 'foolz/foolframe'], $name_lowercase => ['context' => $this->config->get('unknown', 'package', 'main.class_context'), 'namespace' => 'foolz/' . $name_lowercase]];
     $dc = new DoctrineConnection($this->getContext(), $this->config);
     $sm = SchemaManager::forge($dc->getConnection(), $dc->getPrefix());
     Schema::load($this->getContext(), $sm);
     $schema_class = '\\Foolz\\' . $class_name . '\\Model\\Schema';
     $schema_class::load($this->getContext(), $sm);
     $sm->commit();
     $this->config->set('foolz/foolframe', 'config', 'modules.installed', $modules);
     $this->config->set('foolz/foolframe', 'config', 'install.installed', true);
     $this->config->save('foolz/foolframe', 'config');
 }
Пример #2
0
 public function action_database_setup()
 {
     if ($this->getPost()) {
         $validator = new Validator();
         $validator->add('hostname', _i('Database Hostname'), [new Trim(), new Assert\NotBlank()])->add('prefix', _i('Table Prefix'), [new Trim()])->add('username', _i('Username'), [new Trim(), new Assert\NotBlank()])->add('database', _i('Database name'), [new Trim(), new Assert\NotBlank()]);
         $validator->validate($this->getPost());
         if (!$validator->getViolations()->count()) {
             $input = $validator->getFinalValues();
             $input['password'] = $this->getPost('password');
             $input['type'] = $this->getPost('type');
             if ($this->install->check_database($input)) {
                 $this->install->setup_database($input);
                 $dc = new DoctrineConnection($this->getContext(), $this->config);
                 $sm = SchemaManager::forge($dc->getConnection(), $dc->getPrefix());
                 Schema::load($this->getContext(), $sm);
                 $sm->commit();
                 $this->install->create_salts();
                 return new RedirectResponse($this->uri->create('install/create_admin'));
             } else {
                 $this->notices->set('warning', _i('Connection to specified database failed. Please check your connection details again.'));
             }
         } else {
             $this->notices->set('warning', $validator->getViolations()->getText());
         }
     }
     $this->process('database_setup');
     $this->param_manager->setParam('method_title', _i('Database Setup'));
     $this->builder->createPartial('body', 'install/database_setup');
     return new Response($this->builder->build());
 }