main.php 16.6 KB
<?php
return [
    'language' => 'ru-RU',
    'vendorPath' => dirname(dirname(__DIR__)) . '/vendor',
    'controllerMap' => [
        'elfinder' => [
            'class' => 'mihaildev\elfinder\Controller',
            'access' => ['@'], //глобальный доступ к фаил менеджеру @ - для авторизорованных , ? - для гостей , чтоб открыть всем ['@', '?']
            'disabledCommands' => ['netmount'], //отключение ненужных команд https://github.com/Studio-42/elFinder/wiki/Client-configuration-options#commands
            'roots' => [
                [
                    'class' => 'mihaildev\elfinder\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-comment' => [
            'class' => \common\modules\comment\Controller::className(),
        ],
    ],
    'components' => [
        'assetManager' => [
            'bundles' => [
                'yii\web\JqueryAsset' =>[
                    'jsOptions' =>  ['position' => \yii\web\View::POS_HEAD]
                ]
            ],
        ],
        'authManager' => [
            'class' => 'yii\rbac\DbManager',
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        'urlManager'   => [
            'enablePrettyUrl' => true,
            'showScriptName'  => false,
            'rules'           => [
                ''                                                                 => 'site/index',
                'login'                                                            => 'login/index',
                'iam'                                                              => 'iam/index',
                'text/<translit:\w+>'                                              => 'text/index',
                '<language:(ru|ua|en)>/text/<translit:\w+>'                        => 'text/index',
                'catalog'                                                          => 'catalog/all',
                'catalog/<translit:\w+>'                                           => 'catalog/index',
                'products/search'                                                  => 'products/search',
                'products/compare'                                                 => 'products/compare',
                'products/<translit:\w+>'                                          => 'products/index',
                'products/<translit_rubric:\w+>/<translit:[\w\-]+>-<id:\d+>'       => 'products/show',
                'news/<translit:\w+>-<id:\d+>'                                     => 'news/show',
                'brends/<translit:[\w\-]+>'                                        => 'brends/show',
                'brends'                                                           => 'brends/index',
                'blog'                                                             => 'articles/index',
                'blog/<translit:[\w\-]+>-<id:\d+>'                                 => 'articles/show',
                '<language:(ru|ua|en)>/<module:\w+>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>',
                '<language:(ru|ua|en)>/<controller:\w+>/<action:\w+>'              => '<controller>/<action>',
                '<language:(ru|ua|en)>/admin'                                      => 'admin/default/index',
                '<language:(ru|ua|en)>/admin/users'                                => 'admin/users/index',
                'admin'                                                            => 'admin/menu/index',
                'admin/users'                                                      => 'admin/users/index',
                'admin/users/save'                                                 => 'admin/users/save',
                'admin/users/delete'                                               => 'admin/users/delete',
                'admin/menu'        => 'admin/menu/index',
                'admin/menu/save'   => 'admin/menu/save',
                'admin/menu/delete' => 'admin/menu/delete',
                'admin/text'        => 'admin/text/index',
                'admin/text/save'   => 'admin/text/save',
                'admin/text/delete' => 'admin/text/delete',
                'admin/catalog'        => 'admin/catalog/index',
                'admin/catalog/save'   => 'admin/catalog/save',
                'admin/catalog/delete' => 'admin/catalog/delete',
                'module/<module:\w+>/<controller:\w+>/<action:\w+>' => '<module>/<controller>/<action>',
            ],
            'class'           => 'common\components\urlManager\LangUrlManager',
            'languages'       => ['ru', 'ua', 'en'],
            'lang'            => 'ru',
            'langParam'       => 'language',
        ],
        'i18n' => [
            'translations' => [
                '*' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@common/translation',
                    'fileMap' => [
                        'app' => 'app.php',
                        'app/error' => 'error.php',
                    ],
                ],
                'app' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'basePath' => '@common/translation',
                    'fileMap' => [
                        'app' => 'app.php',
                        'app/error' => 'error.php',
                    ],
                ],
            ],
        ],
    ],

    'modules' => [
        'file' => [
            'class' => 'common\modules\file\Module',
        ],
        'relation' => [
            'class' => 'common\modules\relation\Module',
            'relations' => [
                'product_categories' => [
                    'name' => Yii::t('product', 'Categories'),
                    'field' => 'categories',
                    'entity1' => [
                        'model' => '\common\modules\product\models\Product',
                        'label' => 'Product',
                        'listField' => 'name',
                        'searchField' => 'name',
                        'key' => 'product_id',
                        'linked_key' => 'product_id',
                    ],
                    'entity2' => [
                        'model' => '\common\modules\product\models\Category',
                        'label' => 'Category',
                        'listField' => 'categoryName.value',
                        'searchField' => 'category_name.value',
                        'searchJoin' => 'categoryName',
                        'key' => 'category_id',
                        'linked_key' => 'category_id',
                        'hierarchy' => [
                            'key' => 'category_id',
                            'parentKey' => 'parent_id',
                        ]
                    ],
                    'via' => [
                        'model' => '\common\modules\product\models\ProductCategory',
                    ]
                ],
                'product_option' => [
                    'name' => Yii::t('product', 'Properties'),
                    'field' => 'options',
                    'entity1' => [
                        'model' => '\common\modules\product\models\Product',
                        'label' => 'Product',
                        'listField' => 'fullname',
                        'key' => 'product_id',
                        'linked_key' => 'product_id',
                    ],
                    'entity2' => [
                        'model' => '\common\modules\rubrication\models\TaxOption',
                        'label' => 'Option',
                        'listField' => 'ValueRenderFlash',
                        'key' => 'tax_option_id',
                        'linked_key' => 'option_id',
                    ],
                    'via' => [
                        'model' => 'common\modules\product\models\ProductOption',
                    ]
                ],
                'tax_group_to_category' => [
                    'name' => Yii::t('product', 'Характеристики по категориям'),
                    'field' => 'group_to_category',
                    'entity1' => [
                        'model' => '\common\modules\rubrication\models\TaxGroup',
                        'label' => 'Group',
                        'listField' => 'name',
                        'key' => 'tax_group_id',
                        'linked_key' => 'entity1_id',
                    ],
                    'entity2' => [
                        'model' => '\common\modules\product\models\Category',
                        'label' => 'Category',
                        'listField' => 'name',
                        'key' => 'category_id',
                        'linked_key' => 'entity2_id',
                        'hierarchy' => [
                            'key' => 'category_id',
                            'parentKey' => 'parent_id',
                        ]
                    ],
                    'via' => [
                        'model' => '\common\modules\relation\models\Relation',
                        'alias' => 'alias',
                    ]
                ],
                /*
                'relation_categories' => [
                    'name' => Yii::t('relation', 'Relation categories'),
                    'field' => 'categories',
                    'entity1' => [
                        'model' => '\common\modules\product\models\Product',
                        'label' => 'Product',
                        'listField' => 'fullname',
                        'key' => 'product_id',
                        'linked_key' => 'product_id',
                    ],
                    'entity2' => [
                        'model' => '\common\modules\rubrication\models\TaxOption',
                        'label' => 'Category',
                        'listField' => 'ValueRenderFlash',
                        'key' => 'tax_option_id',
                        'linked_key' => 'category_id',
                        'where' => [
                            'tax_group_id' => 1
                        ]
                    ],
                    'via' => [
                        'model' => '\common\modules\relation\models\Relation',
                        'alias' => 'alias',
                    ]
                ],
                'tax_option_to_group' => [
                    'name' => 'Options-Groups',
                    'field' => 'tax_option_to_group',
                    'linked_table' => 'tax_option_to_group',
                    'entity1' => [
                        'label' => 'Option',
                        'listField' => 'ValueRenderFlash',
                        'model' => '\common\modules\rubrication\models\TaxOption',
                        'key' => 'tax_option_id',
                        'linked_key' => 'tax_option_id',
                    ],
                    'entity2' => [
                        'label' => 'Group',
                        'listField' => 'name',
                        'model' => '\common\modules\rubrication\models\TaxGroup',
                        'key' => 'tax_group_id',
                        'linked_key' => 'tax_group_id',
                    ],
                    'via' => [
                        'model' => 'common\modules\rubrication\models\TaxOptionToGroup',
                        'alias' => 'alias',
                    ]
                ],
                'tax_option_to_option' => [
                    'name' => 'Options-Options',
                    'field' => 'tax_option_to_option',
                    'entity1' => [
                        'label' => 'Option',
                        'listField' => 'ValueRenderFlash',
                        'model' => '\common\modules\rubrication\models\TaxOption',
                        'key' => 'tax_option_id',
                        'linked_key' => 'tax_option1_id',
                    ],
                    'entity2' => [
                        'label' => 'Option',
                        'listField' => 'ValueRenderFlash',
                        'model' => '\common\modules\rubrication\models\TaxOption',
                        'key' => 'tax_option_id',
                        'linked_key' => 'tax_option2_id',
                    ],
                    'via' => [
                        'model' => 'common\modules\rubrication\models\TaxOptionRelation',
                        'alias' => 'alias',
                    ]
                ],
                'brand_cats' => [
                    'name' => 'Категории производителей',
                    'field' => 'tax_option_to_option',
                    'entity1' => [
                        'label' => 'Бренд',
                        'listField' => 'ValueRenderFlash',
                        'model' => '\common\modules\rubrication\models\TaxOption',
                        'key' => 'tax_option_id',
                        'linked_key' => 'tax_option1_id',
                    ],
                    'entity2' => [
                        'label' => 'Категория',
                        'listField' => 'ValueRenderFlash',
                        'model' => '\common\modules\rubrication\models\TaxOption',
                        'key' => 'tax_option_id',
                        'linked_key' => 'tax_option2_id',
                    ],
                    'via' => [
                        'model' => 'common\modules\rubrication\models\TaxOptionRelation',
                        'alias' => 'alias',
                    ]
                ]*/
            ]
        ],
        'comment' => [
            'class' => 'common\modules\comment\Module',
            'useRbac' => true,
            'rbac' => [
                'rules' => [
                    \common\modules\comment\rbac\ArtboxCommentCreateRule::className(),
                    \common\modules\comment\rbac\ArtboxCommentDeleteRule::className(),
                    \common\modules\comment\rbac\ArtboxCommentUpdateRule::className(),
                    \common\modules\comment\rbac\ArtboxCommentUpdateOwnRule::className(),
                    \common\modules\comment\rbac\ArtboxCommentDeleteOwnRule::className(),
                ],
                'permissions' => [
                    [
                        'name' => common\modules\comment\Permissions::CREATE,
                        'description' => 'Can create comments',
                        'ruleName' =>(new \common\modules\comment\rbac\ArtboxCommentCreateRule())->name,
                    ],
                    [
                        'name' => common\modules\comment\Permissions::UPDATE,
                        'description' => 'Can update comments',
                        'ruleName' =>(new \common\modules\comment\rbac\ArtboxCommentUpdateRule())->name,
                    ],
                    [
                        'name' => common\modules\comment\Permissions::DELETE,
                        'description' => 'Can delete comments',
                        'ruleName' =>(new \common\modules\comment\rbac\ArtboxCommentDeleteRule())->name,
                    ],
                    [
                        'name' => common\modules\comment\Permissions::UPDATE_OWN,
                        'description' => 'Can update own comments',
                        'ruleName' =>(new \common\modules\comment\rbac\ArtboxCommentUpdateOwnRule())->name,
                    ],
                    [
                        'name' => common\modules\comment\Permissions::DELETE_OWN,
                        'description' => 'Can delete own comments',
                        'ruleName' =>(new \common\modules\comment\rbac\ArtboxCommentDeleteOwnRule())->name,
                    ],
                ],
            ],

        ],
    ],
];