本文整理汇总了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;
}