Example #1
0
 public function actionCreate()
 {
     $model = new Applications();
     if (Yii::$app->zoo->frontendPath === null || !is_dir(Yii::getAlias(Yii::$app->zoo->frontendPath))) {
         $model->app_alias = '@app';
     } else {
         $model->app_alias = Yii::$app->zoo->frontendPath;
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $controller = strtolower($model->name);
         $urlRules = "<code>" . \yii\helpers\Html::encode("'{$controller}/search'=>'{$controller}/default/search',\n\n                '{$controller}/<b:[\\w\\-]+>/<c:[\\w\\-]+>/<d:[\\w\\-]+>/<e:[\\w\\-]+>'=>'{$controller}/default/abcde',\n\n                '{$controller}/<b:[\\w\\-]+>/<c:[\\w\\-]+>/<d:[\\w\\-]+>'=>'{$controller}/default/abcd',\n\n                '{$controller}/<b:[\\w\\-]+>/<c:[\\w\\-]+>'=>'{$controller}/default/abc',\n\n                '{$controller}/<b:[\\w\\-]+>'=>'{$controller}/default/ab',\n\n                '{$controller}'=>'{$controller}/default/index',") . "</code>";
         Yii::$app->getSession()->setFlash('success', Yii::t('backend', 'Приложение добавлено. Добавьте в web.php правила для обработки ссылок' . $urlRules));
         return $this->redirect(['index']);
     }
     return $this->render('create', ['model' => $model]);
 }
Example #2
0
 public function getApp()
 {
     if ($this->application === null) {
         if (($this->application = Applications::findOne(Yii::$app->request->get('app'))) === null) {
             throw new NotFoundHttpException('The requested page does not exist.');
         }
     }
     return $this->application;
 }
Example #3
0
 public function rules()
 {
     return [['name', 'required', 'when' => function ($model) {
         return $model->isNewRecord;
     }], ['name', 'match', 'pattern' => '#^[\\w_]+$#i', 'when' => function ($model) {
         return $model->isNewRecord;
     }], ['name', 'unique', 'targetClass' => Applications::className(), 'message' => Yii::t('backend', 'Такое приложение уже есть')], ['name', 'string', 'min' => 2, 'max' => 255, 'when' => function ($model) {
         return $model->isNewRecord;
     }], ['name', 'controllerFileExists', 'when' => function ($model) {
         return $model->isNewRecord;
     }], ['name', 'viewFolderExists', 'when' => function ($model) {
         return $model->isNewRecord;
     }], ['model_table_name', 'match', 'pattern' => '#^[\\w_}{\\%}]+$#i'], ['model_table_name', 'tableExists', 'when' => function ($model) {
         return $model->isNewRecord;
     }], ['model_table_name', 'modelFileExists', 'when' => function ($model) {
         return $model->isNewRecord;
     }], ['example', 'exampleExists', 'when' => function ($model) {
         return $model->isNewRecord;
     }], [['filters', 'itemsSearch', 'itemsSort', 'defaultOrderDesc', 'itemsColumns', 'defaultPageSize'], 'integer'], ['simpleItemLinks', 'integer'], ['title', 'required'], ['title', 'string', 'max' => 255], ['app_alias', 'validateAppAlias'], [['content', 'intro', 'metaDescription', 'metaKeywords'], 'string'], [['metaTitle', 'defaultOrder'], 'string', 'max' => 255]];
 }
Example #4
0
 public function getApp()
 {
     return $this->hasOne(Applications::className(), ['id' => 'app_id']);
 }