public function can($permissionName, $params = [], $allowCaching = true) { if (Yii::$app->user->identity->isSuperadmin) { return true; } try { $rp = RolePermission::findOne(['roleName' => Yii::$app->user->identity->role, 'permissionName' => $permissionName]); if ($rp) { return true; } } catch (Exception $e) { } return false; }
/** * Finds the RolePermission model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $_id * @return RolePermission the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = RolePermission::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }