public function up()
 {
     // Creates folders for media manager
     $webroot = Yii::getAlias('@app/web');
     foreach (['upload', 'files'] as $folder) {
         $path = $webroot . '/' . $folder;
         if (!file_exists($path)) {
             echo "mkdir('{$path}', 0777)...";
             if (mkdir($path, 0777, true)) {
                 echo "done.\n";
             } else {
                 echo "failed.\n";
             }
         }
     }
     // Creates the default platform config
     /** @var \gromver\platform\basic\console\modules\main\Module $main */
     $cmf = Yii::$app->grom;
     $paramsPath = Yii::getAlias($cmf->paramsPath);
     $paramsFile = $paramsPath . DIRECTORY_SEPARATOR . 'params.php';
     $params = $cmf->params;
     $model = new \gromver\models\ObjectModel(\gromver\platform\basic\modules\main\models\PlatformParams::className());
     $model->setAttributes($params);
     echo 'Setup application config: ' . PHP_EOL;
     $this->readStdinUser('Site Name (My Site)', $model, 'siteName', 'My Site');
     $this->readStdinUser('Admin Email (admin@email.com)', $model, 'adminEmail', '*****@*****.**');
     $this->readStdinUser('Support Email (support@email.com)', $model, 'supportEmail', '*****@*****.**');
     if ($model->validate()) {
         \yii\helpers\FileHelper::createDirectory($paramsPath);
         file_put_contents($paramsFile, '<?php return ' . var_export($model->toArray(), true) . ';');
         @chmod($paramsFile, 0777);
     }
     echo 'Setup complete.' . PHP_EOL;
 }
 public function actionParams($modal = null)
 {
     $paramsPath = Yii::getAlias($this->module->paramsPath);
     $paramsFile = $paramsPath . DIRECTORY_SEPARATOR . 'params.php';
     $params = $this->module->params;
     $model = new ObjectModel(PlatformParams::className());
     $model->setAttributes($params);
     if ($model->load(Yii::$app->request->post())) {
         if ($model->validate() && Yii::$app->request->getBodyParam('task') !== 'refresh') {
             FileHelper::createDirectory($paramsPath);
             try {
                 file_put_contents($paramsFile, '<?php return ' . var_export($model->toArray(), true) . ';');
                 @chmod($paramsFile, 0777);
                 Yii::$app->session->setFlash(Alert::TYPE_SUCCESS, Yii::t('gromver.platform', 'Configuration saved.'));
                 if ($modal) {
                     ModalIFrame::refreshParent();
                 }
             } catch (\Exception $e) {
                 Yii::$app->session->setFlash(Alert::TYPE_DANGER, $e->getMessage());
             }
         }
     }
     if ($modal) {
         Yii::$app->grom->applyModalLayout();
     }
     return $this->render('params', ['model' => $model]);
 }