main.php 7.06 KB
<?php
use common\behaviors\ArtBoxAccessBehavior;
$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__),
    'controllerMap' => [
        'elfinder' => [
            'class' => 'mihaildev\elfinder\Controller',
            'access' => ['@'], //глобальный доступ к фаил менеджеру @ - для авторизорованных , ? - для гостей , чтоб открыть всем ['@', '?']
            'disabledCommands' => ['netmount'], //отключение ненужных команд https://github.com/Studio-42/elFinder/wiki/Client-configuration-options#commands
            'roots' => [
                [
                    'class' => 'mihaildev\elfinder\volume\UserPath',
                    'path'  => '../../storage/user_{id}',
                    'name'  => 'My Documents'
                ],
            ],
            'watermark' => [
                'source'         => __DIR__.'/logo.png', // Path to Water mark image
                'marginRight'    => 5,          // Margin right pixel
                'marginBottom'   => 5,          // Margin bottom pixel
                'quality'        => 95,         // JPEG image save quality
                'transparency'   => 70,         // Water mark image transparency ( other than PNG )
                'targetType'     => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
                'targetMinPixel' => 200         // Target image minimum pixel size
            ]
        ],
        'artbox-comments' => [
            'class' => 'common\modules\comment\controllers\ManageController',
            'viewPath' => '@common/modules/comment/views/manage',
        ],
    ],
    'layout' => 'admin',
    'controllerNamespace' => 'backend\controllers',
    'bootstrap' => ['log'],
    'as AccessBehavior' => [
        'class' => ArtBoxAccessBehavior::className(),
        'rules' =>
            [
                'permit/access' =>
                [
                    [
                        'actions' => ['role', 'permission','add-role', 'update-role','add-permission', 'update-permission' ],
                        'allow' => true,
                    ]
                ],
                'site' =>
                [
                    [
                        'actions' => ['login', 'error','logout',],
                        'allow' => true,
                    ],
                    [
                        'actions' => ['index'],
                        'allow' => true,
                        'roles' => ['@'],
                    ],
                    [
                        'actions' => ['images'],
                        'allow' => true,
                        'roles' => ['@'],
                    ]

                ],
                'file/uploader' =>[
                    [
                        'actions' => ['images-upload'],
                        'allow' => true,
                    ]
                ],
                'elfinder' => [
                    [
                        'actions' => ['manager','connect'],
                        'allow' => true,
                    ]
                ]


            ]
    ],
    'modules' => [
        'permit' => [
            'class' => 'developeruz\db_rbac\Yii2DbRbac',
            'params' => [
                'userClass' => 'backend\models\User'
            ]
        ],

        'rubrication' => [
            'class' => 'common\modules\rubrication\Module',
            'types' => [
                'string' => 'Strings',
                'float' => 'Floating number',
                'int' => 'Integer number',
                'link' => 'Web-link',
            ]
        ],
        'product' => [
            'class' => 'common\modules\product\Module'
        ],
        'gridview' =>  [
            'class' => '\kartik\grid\Module'
        ],
        'artbox-comment' => [
            'class' => 'common\modules\comment\Module',
            'userIdentityClass' => 'common\models\Customer',
        ],
    ],
    'components' => [
        'assetManager' => [
            'bundles' => [
                'yii\web\JqueryAsset' =>[
                    'jsOptions' =>  ['position' => \yii\web\View::POS_HEAD]
                ]
            ],
        ],
        'authManager' => [
            'class' => 'yii\rbac\DbManager',
        ],
        'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'imageCache' => [
            'class' => 'iutbay\yii2imagecache\ImageCache',
            'sourcePath' => '@storage',
            'sourceUrl' => '/storage',
            'thumbsPath' => '@storage/thumbs',
            'thumbsUrl' => '/storage/thumbs',

            'sizes' => [
                'slider' => [720, 340],
            ],
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'request'=>[
            'cookieValidationKey' => 'j4iuot9u5894e7tu8reyh78g9y54sy7i',
            'csrfParam' => '_backendCSRF',

            'class' => 'common\components\Request',

            'web'=> '/backend/web',

            'adminUrl' => '/admin'

        ],
        'urlManager' => [
            'baseUrl' => '/admin',
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules' => [
                'slider-image/<action>/<slider_id:[A-Za-z0-9_-]+>/<id:[A-Za-z0-9_-]+>' => 'slider-image/<action>',
                'slider-image/<action>/<slider_id:[A-Za-z0-9_-]+>' => 'slider-image/<action>',
                'rubrication/tax-group/<level:[0-9]+>' => 'rubrication/tax-group',
                'rubrication/tax-group/<action>/<level:[0-9]+>/<id:[A-Za-z0-9_-]+>' => 'rubrication/tax-group/<action>',
                'rubrication/tax-group/<action>/<level:[0-9]+>' => 'rubrication/tax-group/<action>',
                'product/manage/<action>' => 'product/manage/<action>',
                'product/<controller>/<action>/<product_id:[A-Za-z0-9_-]+>/<id:[A-Za-z0-9_-]+>' => 'product/<controller>/<action>',
                'product/<controller>/<action>/<product_id:[A-Za-z0-9_-]+>/' => 'product/<controller>/<action>',
                'product/<action>/<product_id:[A-Za-z0-9_-]+>' => 'product/<action>',
                'seo-dynamic/<action>/<seo_category_id:[A-Za-z0-9_-]+>/<id:[A-Za-z0-9_-]+>' => 'seo-dynamic/<action>',
                'seo-dynamic/<action>/<seo_category_id:[A-Za-z0-9_-]+>' => 'seo-dynamic/<action>',
            ]
        ]

    ],
    'params' => $params,
];