本文整理匯總了PHP中app\models\Role::accessFilter方法的典型用法代碼示例。如果您正苦於以下問題:PHP Role::accessFilter方法的具體用法?PHP Role::accessFilter怎麽用?PHP Role::accessFilter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\models\Role
的用法示例。
在下文中一共展示了Role::accessFilter方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionIndex
public function actionIndex()
{
$methods = Role::$methods;
$fields = Role::accessFilter();
$controllers = Role::$controllers;
$roleId = isset($_GET['roleId']) == null ? 1 : $_GET['roleId'];
$model = $this->findModel($roleId);
$model->role_name = $roleId;
$sql = '';
//echo '<pre>';print_r($_POST['Roles']); exit(0);
if ($model->load(Yii::$app->request->post())) {
\app\models\Access::deleteAll('roleId = :roleId', [':roleId' => $roleId]);
foreach ($_POST['Roles'] as $keys => $values) {
foreach ($values as $k => $v) {
//if($v=='on')
$sql .= ' INSERT INTO access (roleId,controller,method) values ("' . $roleId . '","' . $keys . '","' . $k . '"); ';
}
}
if ($sql) {
Yii::$app->db->createCommand($sql)->execute();
Yii::$app->session->setFlash('success', 'Successfully, Update access role!');
}
}
return $this->render('index', ['model' => $model, 'methods' => $methods, 'fields' => $fields, 'controllers' => $controllers, 'roleId' => $roleId]);
}
示例2: fieldsArray
public static function fieldsArray()
{
$fields = \app\models\Role::accessFilter();
$return = [];
foreach ($fields as $keys => $values) {
foreach ($values as $k => $v) {
$return[] = strtolower($keys) . '.' . $v;
}
}
return $return;
}