/** * Creates a new AuthItem model. * If creation is successful, the browser will be redirected to the 'view' page. * * @return mixed */ public function actionCreate() { $model = new AuthItem(); if ($model->load(Yii::$app->request->post())) { $item = $this->model2Item($model, new Permission()); $this->auth->add($item); $categoryName = YiiForum::getPostValue('AuthItem')['category']; $category = new Permission(); if ($categoryName) { $category->name = $categoryName; $this->auth->addChild($category, $item); } else { $rootPermission = $this->auth->getPermission('root_permission'); if (!$rootPermission) { $model2 = new AuthItem(); $model2->name = 'root_permission'; $model2->description = '权限根'; $model2->rule_name = ''; $model2->data = ''; $item2 = $this->model2Item($model2, new Permission()); $this->auth->add($item2); } $category->name = 'root_permission'; $this->auth->addChild($category, $item); AuthItem::createCachedPermissionsGroup(); } return $this->redirect(['index']); } else { $locals = []; $locals['groups'] = YiiForum::getAppParam('cachedPermissionsGroup'); $locals['model'] = $model; //var_dump(Yii::$app->params); //exit; return $this->render('create', $locals); } }