/** * Assign route action * * @param $action * @return string[] */ public function actionAssign($action) { Yii::$app->getResponse()->format = Response::FORMAT_JSON; $post = Yii::$app->getRequest()->post(); $routes = ArrayHelper::getValue($post, 'routes', []); $manager = Yii::$app->getAuthManager(); $model = new RouteModel(); if ($action == 'assign') { $model->save($routes); } else { foreach ($routes as $route) { $child = $manager->getPermission($route); $manager->remove($child); } } return [$this->actionRouteSearch('available', $post['search_av']), $this->actionRouteSearch('assigned', $post['search_asgn'])]; }
/** * Refresh cache of routes */ public function actionRefresh() { $model = new RouteModel(); $model->invalidate(); return $model->getRoutes(); }