/** * [init description]. * * @return [type] [description] */ public function init() { parent::init(); $this->ctype = 'user'; $this->uuid = !empty(\Yii::$app->getRequest()->getQueryParam('uuid')) ? \Yii::$app->getRequest()->getQueryParam('uuid') : null; // create default user element, if none is present $workspacePath = realpath(\Yii::getAlias('@webroot') . '/../workspace'); if ($workspacePath === false) { throw new \yii\web\ServerErrorHttpException('The *workspace* folder could not be found - please create it in your project root'); } $elementsPath = realpath($workspacePath . '/elements'); if ($elementsPath === false) { throw new \yii\web\ServerErrorHttpException('The *elements* folder could not be found - please create it in your workspace folder'); } $modelJson = realpath($elementsPath . '/' . $this->ctype . '.json'); if ($modelJson === false) { file_put_contents($elementsPath . '/' . $this->ctype . '.json', '{"key":"user","label":"User","tabs":[{"label":"Login","key":"login","visible":false,"groups":[{"label":"Login","key":"login","fields":["email","password","login"]}]},{"label":"User","key":"user","groups":[{"label":"User","key":"user","fields":["email","password","state"]}]}],"fields":[{"label":"Email address","key":"email","type":"textInput","visibleInGrid":true,"rules":[["required"],["email"],["string",{"max":128}]]},{"label":"Password","key":"password","type":"passwordInput","visibleInGrid":false,"rules":[["required"],["string",{"max":128}]],"transform":"hash"},{"label":"Login","key":"login","type":"submitButton","visibleInGrid":false}, {"label":"Auth-Key","key":"authKey","type":"text","visibleInGrid":false}]}'); } \Yii::$app->cache->flush(); $usersProvider = new CrelishJsonDataProvider('user'); $users = $usersProvider->rawAll(); if (sizeof($users) == 0) { // Generate default admin. $adminUser = new CrelishDynamicJsonModel(['email', 'password', 'login', 'state'], ['ctype' => 'user']); $adminUser->email = '*****@*****.**'; $adminUser->login = '******'; $adminUser->password = '******'; $adminUser->state = 1; $adminUser->authKey = \Yii::$app->security->generateRandomString(); $adminUser->save(); } }
/** * [init description] * @return [type] [description] */ public function init() { parent::init(); $this->ctype = !empty(\Yii::$app->getRequest()->getQueryParam('ctype')) ? \Yii::$app->getRequest()->getQueryParam('ctype') : 'page'; $this->uuid = !empty(\Yii::$app->getRequest()->getQueryParam('uuid')) ? \Yii::$app->getRequest()->getQueryParam('uuid') : null; }
public function init() { parent::init(); }