Настройка GII в Yii2
Использование проверки в фильтре доступа AccessControl
<?php
public function behaviors() {
return [
'access' => [
'class' => \yii\filters\AccessControl::className(),
'rules' => [
[
'allow' => true,
'roles' => ['viewAdminModule']
],
],
],
];
}
виду, что если роль админа наследует роль редактора новостей, то для админа Yii::$app->user->can('editor'))
вернет true.
<?php
$config = [ ‘components’ => [ ‘request’ => [ ‘cookieValidationKey’ => ‘7MQaVU9ni89QYc0n7UJSOJaJowoY-JC_’, ], ], ];
if (!YII_ENV_TEST) { // configuration adjustments for ‘dev’ environment $config[‘bootstrap’][] = ‘debug’; $config[‘modules’][‘debug’] = [ ‘class’ => ‘yii\debug\Module’, ];
$config['bootstrap'][] = 'gii';
$config['modules']['gii'] = [
'class' => 'yii\gii\Module',
'generators' => [
'model' => [
'class' => 'yii\gii\generators\model\Generator',
'baseClass' => 'common\components\SModel',
'ns' => 'common\models',
'generateLabelsFromComments' => true
]
]
]; }
return $config;