microinginer/yii2-debug-user-switch

User switcher

Installs: 4 610

Dependents: 0

Suggesters: 0

Security: 0

Stars: 5

Watchers: 1

Forks: 0

Open Issues: 2

Type:yii2-extensions

v1.0.0 2016-10-17 10:47 UTC

This package is auto-updated.

Last update: 2021-02-08 17:50:08 UTC


README

This extension for yii2-debug. Use only development environment.

Install

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist microinginer/yii2-debug-user-switch:"dev-master"

or add

"microinginer/yii2-debug-user-switch":"dev-master"

to the require section of your composer.json file.

Configuration

// config/web.php

if (YII_ENV_DEV) {
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
        ...
        'panels' => [
            'switchUser' => [
                'class' => 'microinginer\switchUser\SwitchPanel',
                'modelClass' => '\app\models\User',
                /*
                'queryCondition' => function (\yii\db\ActiveQuery &$query, \yii\db\ActiveRecord $model) {
                    $query->andWhere('suborg_id IS NOT NULL');
                },
                'gridViewColumns' => [
                    'full_name',
                    [
                        'attribute' => 'org.name',
                        'label' => 'Organization',
                    ],
                    [
                        'label' => Yii::t('app', 'Roles'),
                        'value' => function ($model) {
                            $roles = '';
                            foreach (Yii::$app->authManager->getRolesByUser($model->id) as $role) {
                                $roles .= ', ' . $role->name;
                            }
                            $roles = substr($roles, 1);
                            return $roles;
                        }
                    ],
                ],
                */
            ]
        ],
        ...
    ];
}