/**
  * Sets application in installed state (disables installer)
  */
 public static function setInstalled()
 {
     // Set App secret
     Yii::$app->config->set(Enum::APP_SECRET, md5(uniqid(time(), TRUE)));
     $param = Configuration::getParam();
     $param[Enum::APP_INSTALLED] = TRUE;
     Configuration::setParam($param);
 }
 /**
  * Setup some initial database settings.
  *
  * This will be done at the first step.
  */
 private function setupInitialData()
 {
     // Get Params File
     $param = Configuration::getParam();
     // Application Title
     Yii::$app->config->set(Enum::APP_NAME, 'Starter Kit');
     // Application Default Backend Theme
     Yii::$app->config->set(Enum::APP_BACKEND_THEME, 'yeti');
     // Application Default Frontend Theme
     Yii::$app->config->set(Enum::APP_FRONTEND_THEME, 'readable');
     // Caching
     Yii::$app->config->set(Enum::CACHE_CLASS, DbCache::className());
     // Admin
     Yii::$app->config->set(Enum::ADMIN_INSTALL_ID, md5(uniqid('', TRUE)));
     // Basic
     Yii::$app->config->set(Enum::APP_TOUR, TRUE);
     // Yii2-User
     Yii::$app->config->set(Enum::USER_REGISTRATION, 1);
     Yii::$app->config->set(Enum::USER_PASSWORD_RESET_TOKEN_EXPIRE, 86400);
     Yii::$app->config->set(Enum::USER_FORGOT_PASSWORD, 1);
     Yii::$app->config->set(Enum::REMEMBER_ME_DURATION, 3600);
     Yii::$app->config->set(Enum::USER_LOGIN_TYPE, 2);
     // Mailer
     Yii::$app->config->set(Enum::MAILER_USE_TRANSPORT, $param['installer']['mail']['useTransport']);
     Yii::$app->config->set(Enum::MAILER_HOST, $param['installer']['mail']['transport']['host']);
     Yii::$app->config->set(Enum::MAILER_USERNAME, $param['installer']['mail']['transport']['username']);
     Yii::$app->config->set(Enum::MAILER_PASSWORD, $param['installer']['mail']['transport']['password']);
     Yii::$app->config->set(Enum::MAILER_PORT, $param['installer']['mail']['transport']['port']);
     Yii::$app->config->set(Enum::MAILER_ENCRYPTION, $param['installer']['mail']['transport']['encryption']);
     // Authentication Clients
     Yii::$app->config->set(Enum::GOOGLE_AUTH, NULL);
     Yii::$app->config->set(Enum::GOOGLE_CLIENT_ID, NULL);
     Yii::$app->config->set(Enum::GOOGLE_CLIENT_SECRET, NULL);
     Yii::$app->config->set(Enum::FACEBOOK_AUTH, NULL);
     Yii::$app->config->set(Enum::FACEBOOK_CLIENT_ID, NULL);
     Yii::$app->config->set(Enum::FACEBOOK_CLIENT_SECRET, NULL);
     Yii::$app->config->set(Enum::LINKED_IN_AUTH, NULL);
     Yii::$app->config->set(Enum::LINKED_IN_CLIENT_ID, NULL);
     Yii::$app->config->set(Enum::LINKED_IN_CLIENT_SECRET, NULL);
     Yii::$app->config->set(Enum::GITHUB_AUTH, NULL);
     Yii::$app->config->set(Enum::GITHUB_CLIENT_ID, NULL);
     Yii::$app->config->set(Enum::GITHUB_CLIENT_SECRET, NULL);
     Yii::$app->config->set(Enum::LIVE_AUTH, NULL);
     Yii::$app->config->set(Enum::LIVE_CLIENT_ID, NULL);
     Yii::$app->config->set(Enum::LIVE_CLIENT_SECRET, NULL);
     Yii::$app->config->set(Enum::TWITTER_AUTH, NULL);
     Yii::$app->config->set(Enum::TWITTER_CONSUMER_KEY, NULL);
     Yii::$app->config->set(Enum::TWITTER_CONSUMER_SECRET, NULL);
 }
 public function actionInstall()
 {
     $model = new InstallerForm();
     $param = Configuration::getParam();
     if ($model->load(Yii::$app->request->post())) {
         $model->install = $model->install === '0' ? TRUE : FALSE;
         $param['installed'] = $model->install;
         Configuration::setParam($param);
     }
     return $this->render('install', ['model' => $model]);
 }
 /**
  * @return array|string|\yii\web\Response
  */
 public function actionMailer()
 {
     $config = Configuration::get();
     $param = Configuration::getParam();
     $mailer = new MailerForm();
     if ($mailer->load(Yii::$app->request->post())) {
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ActiveForm::validate($mailer);
         }
         if ($mailer->validate()) {
             if ($mailer->useTransport === '0') {
                 $mailer->useTransport = FALSE;
             } else {
                 $mailer->useTransport = TRUE;
             }
             // Write Config
             $config['components']['mail']['class'] = Mailer::className();
             $config['components']['mail']['useTransport'] = $mailer->useTransport;
             $config['components']['mail']['transport']['class'] = 'Swift_SmtpTransport';
             $config['components']['mail']['transport']['host'] = $mailer->host;
             $config['components']['mail']['transport']['username'] = $mailer->username;
             $config['components']['mail']['transport']['password'] = $mailer->password;
             $config['components']['mail']['transport']['port'] = $mailer->port;
             $config['components']['mail']['transport']['encryption'] = $mailer->encryption;
             // Write config for future use
             $param['installer']['mail']['useTransport'] = $mailer->useTransport;
             $param['installer']['mail']['transport']['host'] = $mailer->host;
             $param['installer']['mail']['transport']['username'] = $mailer->username;
             $param['installer']['mail']['transport']['password'] = $mailer->password;
             $param['installer']['mail']['transport']['port'] = $mailer->port;
             $param['installer']['mail']['transport']['encryption'] = $mailer->encryption;
             Configuration::set($config);
             Configuration::setParam($param);
             return $this->redirect(Yii::$app->urlManager->createUrl('//installer/setup/init'));
         }
     } else {
         if (isset($param['installer']['mail']['transport']['host'])) {
             $mailer->host = $param['installer']['mail']['transport']['host'];
         }
         if (isset($param['installer']['mail']['transport']['username'])) {
             $mailer->username = $param['installer']['mail']['transport']['username'];
         }
         if (isset($param['installer']['mail']['transport']['password'])) {
             $mailer->password = $param['installer']['mail']['transport']['password'];
         }
         if (isset($param['installer']['mail']['transport']['port'])) {
             $mailer->port = $param['installer']['mail']['transport']['port'];
         }
         if (isset($param['installer']['mail']['transport']['encryption'])) {
             $mailer->encryption = $param['installer']['mail']['transport']['encryption'];
         }
     }
     return $this->render('mailer', ['model' => $mailer]);
 }