public function run($formData, $step, &$state) { $response = parent::run($formData, $step, $state); if (!$response->isSuccessful()) { return $response; } $stepsData = []; foreach ($state['steps'] as $aStep) { if ($stepData = $aStep->getData()) { $stepsData = array_merge($stepsData, $stepData); } } unset($stepsData['languages']); unset($_SESSION['install_locale']); InstallerUtils::createConfig($stepsData, BASE_PATH . '/api'); InstallerUtils::createTables(BASE_PATH); InstallerUtils::addDefaultSettings($stepsData, BASE_PATH); $stepsData = InstallerUtils::addDefaultUser($stepsData); InstallerUtils::installSchema($stepsData['db_schema'], BASE_PATH); $data = ['user' => ['email' => $stepsData['directus_email'], 'token' => $stepsData['user_token'], 'password' => $stepsData['directus_password']], 'project' => ['name' => $stepsData['directus_name'], 'version' => DIRECTUS_VERSION, 'url' => get_url()], 'database' => ['host' => $stepsData['db_host'], 'name' => $stepsData['db_name'], 'user' => $stepsData['db_user'], 'password' => $stepsData['db_password']]]; if ($response->getData('send_config_email')) { Mail::send('mail/new-install.twig.html', $data, function ($message) use($data) { $message->setSubject(__t('your_new_directus_instance_x', ['name' => $data['project']['name']])); $message->setTo($data['user']['email']); }); } return $response; }
public function testCreateFiles() { InstallerUtils::createConfig(['db_type' => 'mysql', 'db_port' => 3306, 'db_host' => 'localhost', 'db_name' => 'directus', 'db_user' => 'root', 'db_password' => 'password', 'directus_path' => '/directus/', 'directus_email' => '*****@*****.**'], __DIR__ . '/'); $this->assertSame(sha1_file(__DIR__ . '/mock/config.sample.php'), sha1_file(__DIR__ . '/config.php')); $this->assertSame(sha1_file(__DIR__ . '/mock/configuration.sample.php'), sha1_file(__DIR__ . '/configuration.php')); }
public function cmdConfig($args, $extra) { $data = []; $data['db_type'] = 'mysql'; $data['db_port'] = '3306'; $data['db_host'] = 'localhost'; $data['db_name'] = 'directus'; $data['db_user'] = '******'; $data['db_password'] = '******'; $data['directus_path'] = '/'; $directus_path = BASE_PATH . DIRECTORY_SEPARATOR; foreach ($args as $key => $value) { switch ($key) { case 't': $data['db_type'] = $value; break; case 'P': $data['db_port'] = $value; break; case 'h': $data['db_host'] = $value; break; case 'n': $data['db_name'] = $value; break; case 'u': $data['db_user'] = $value; break; case 'p': $data['db_password'] = $value; break; case 'r': $data['directus_path'] = $value; break; case 'd': $directus_path = $directus_path . $value; break; } } InstallerUtils::createConfig($data, $directus_path . 'api'); }
private function createConfig() { // add default information // prevent issue with the new installation $data = ['db_type' => 'mysql', 'host' => 'localhost', 'db_port' => 3306, 'directus_path' => '/']; $options = $this->options; foreach ($options as $key => $value) { switch ($key) { case 'h': case 'host': $data['db_host'] = $value; unset($options[$key]); break; case 'n': case 'name': $data['db_name'] = $value; unset($options[$key]); break; case 'u': case 'user': $data['db_user'] = $value; unset($options[$key]); break; case 'p': case 'pass': $data['db_password'] = $value; unset($options[$key]); break; case 'd': case 'dir': $data['directus_path'] = $value; unset($options[$key]); break; } } InstallerUtils::createConfig($data, $this->directusPath . '/api'); $this->clear(); }