<?php
$params = array_merge(
    require(__DIR__ . '/../../common/config/params.php'),
    require(__DIR__ . '/../../common/config/params-local.php'),
    require(__DIR__ . '/params.php'),
    require(__DIR__ . '/params-local.php')
);

return [
    'id' => 'app-backend',
    'basePath' => dirname(__DIR__),
    'controllerNamespace' => 'backend\controllers',
    'language' => 'zh-CN',
    'bootstrap' => ['log'],
    'modules' => [
        'user' => [
            'class' => 'backend\modules\user\Module',
        ],
        'ib' => [
            'class' => 'backend\modules\ib\Module',
        ],
    ],
    'components' => [
        'request' => [
            'csrfParam' => '_csrf-backend',
        ],
        'user' => [
            'identityClass' => 'backend\models\MemberIdentity',
            'identityCookie' => ['name' => '_identity-backend', 'httpOnly' => true],
            'loginUrl' => ['account/login'],
            'idParam' => '__id',
            'authTimeoutParam' => '__expire',
            'absoluteAuthTimeoutParam' => '__absoluteExpire',
            'returnUrlParam' => '__returnUrl',
            'as loginCookie' => [
                'class' => 'common\behaviors\LoginCookieBehavior',
            ],
        ],
        'userIb' => [
            'class' => 'yii\web\User',
            'identityClass' => 'backend\models\MemberIdentity',
            'identityCookie' => ['name' => '_identity-backend-ib', 'httpOnly' => true],
            'loginUrl' => ['account/iblogin'],
            'idParam' => '__id_ib',
            'authTimeoutParam' => '__expire_ib',
            'absoluteAuthTimeoutParam' => '__absoluteExpire_ib',
            'returnUrlParam' => '__returnUrl_ib',
            'as loginCookie' => [
                'class' => 'common\behaviors\LoginCookieBehavior',
            ],
        ],
        'session' => [
            // this is the name of the session cookie used for login on the backend
            'name' => 'advanced-backend',
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                'pay/notify/<payType>' => 'pay/notify',
                'pay/return/<payType>' => 'pay/return',
                'remit/notify/<remitNo>' => 'remit/notify',
                'ibLogin' => 'account/iblogin',
                'login' => 'account/login',
                'account/openDemo' => 'account/opendemo',
            ],
        ],
        'assetManager' => [
            'bundles' => [
                'yii\web\JqueryAsset' => [
                    'sourcePath' => null,
                    'basePath' => '@webroot',
                    'baseUrl' => '@web',
                    'js' => [
                        'ui/js/jquery.1.9.1.min.js',
                    ],
                ],
            ],
        ],
    ],
    'params' => $params,
];
