Yii2 Yii2-user dektrium configuration

File web.php

<?php $params = require(__DIR__ . '/params.php');

$config = [
    'id' => 'basic',
    'name' => 'Droidy Rater v1.0',
    'basePath' => dirname(__DIR__),


    'language' => //'en',
        'en', //Язык приложения ru-RU

    'charset' => 'utf-8',
    'timeZone' => 'Europe/Minsk',

    'bootstrap' => [
        //  'languagepicker', //language
        'log',
        //'app\base\config', //custom rat options

    ],
    'components' => [


        'i18n' => [
            'translations' => [
                'app*' => [        //app*      //app
                    'class' => 'yii\i18n\PhpMessageSource',

                    /*
                     * Именно для принудительной обработки переводов в конфигурации нашего источника
                     *  у транслятора мы установили параметр forceTranslation в true
                     * */

                    'forceTranslation' => true,
                    'basePath' => '@app/messages', //@webroot
                    'sourceLanguage' => 'en-US', //en-US
                    'fileMap' => [
                        //'main' => 'main.php',
                        //'app'       => 'app.php',
                        //'app/error' => 'error.php',
                    ],
                ],

                '*' => [
                    'class' => 'yii\i18n\PhpMessageSource'
                ],

                'pages*' => [
                    'class' => 'yii\i18n\PhpMessageSource',
                    'sourceLanguage' => 'en-US',
                    'forceTranslation' => true,
                    'basePath' => 'app/modules/pages/messages',
                    'fileMap' => [
                        '/app/modules/pages/messages' => 'core.php',
                    ],
                ],


            ],
        ],

        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => '3LhzBk4mWrBMg5K9rUZsgtFPKhu7a9kJ',
            //Обработка URL для определения языка
            'class' => 'app\components\LangRequest'
        ],

       
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],

        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            'viewPath' => '@app/mailer',
            'useFileTransport' => false,
            'transport' => [
                'class' => 'Swift_SmtpTransport',
                'host' => 'your-host-domain e.g. smtp.gmail.com',
                'username' => 'your-email-or-username',
                'password' => 'your-password',
                'port' => '587',
                'encryption' => 'tls',
            ],
        ],

        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],

//Yii::$app->db
        /*
         * MySQL, MariaDB: mysql:host=localhost;dbname=mydatabase
SQLite: sqlite:/path/to/database/file
PostgreSQL: pgsql:host=localhost;port=5432;dbname=mydatabase
CUBRID: cubrid:dbname=demodb;host=localhost;port=33000
MS SQL Server (via sqlsrv driver): sqlsrv:Server=localhost;Database=mydatabase
MS SQL Server (via dblib driver): dblib:host=localhost;dbname=mydatabase
MS SQL Server (via mssql driver): mssql:host=localhost;dbname=mydatabase
Oracle: oci:dbname=//localhost:1521/mydatabase
         * */

        'db' => require(__DIR__ . '/db.php'),

        'connection' => function () {
            return new yii\db\Connection(Yii::$app->db); //custom function
        },

//===========================================================
        //Custom shared options
        'options' =>[
            'class' => 'app\modules\control\components\Functions',
            'password' => 'B3Wn6LL9HB',
            'upload_path' => 'upload/',
       

        ],

        //RBAC
        'authManager' => [
            'class' => 'yii\rbac\PhpManager',
            //-   'siteRoles' => ['user', 'admin'],

            'itemFile' => '@app/rbac/items.php',
            'assignmentFile' => '@app/rbac/assignments.php',
            'ruleFile' => '@app/rbac/rules.php'
        ],

            'user' => [
                   //standart class >>'identityClass' => 'app\models\User',

                    //enable    dektrium
                    'identityClass' => 'dektrium\user\models\User',
                    'enableAutoLogin' => true,
               ],
       

        'urlManager' => [
            'enablePrettyUrl' => true,
            'showScriptName' => false, //Не писать в адресе /index.php/


            'class'=>'app\components\LangUrlManager', //<--
            'rules' => [


                //module pages
                //pages/site/index?pages=howwork


                //'howwork' => 'pages/site/index?pages=howwork',

                //'pages/<pages:[\w-]+>' => 'pages/site/index',
                //'manager' => 'pages/manager/index',     //Ok...





                '<language:(ru|en|de)>' => 'site/index',
                '/' => 'site/index',

                '<language:(ru|en|de)>/<action:(contact|login|logout)>' => 'site/<action>',
                '<action:(contact|login|logout)>' => 'site/<action>',

                '<language:(ru|en|de)>/<controller:\w+>/<id:\d+>'=>'<controller>/view',
                '<controller:\w+>/<id:\d+>'=>'<controller>/view',

                '<language:(ru|en|de)>/<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
                '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',

                '<language:(ru|en|de)>/<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',

            ],
        ],






        //Правим конфиги для модулю customuser

        //-   'user' => [


        //  'class' => 'app\models\User', // <-- Your own user component class goes here
        //  'identityClass' => 'dektrium\user\models\User',

        //'class' => '\dektrium\user\components\User',
        //'identityClass' => 'app\models\User' // <-- Your new identity class goes here
        //-   ],


        /*
    'languagepicker' => [
        'class' => 'lajax\languagepicker\Component',
        //'languages' => ['en', 'de', 'fr', 'ru-RU'],                   // List of available languages (icons only)

        'languages' => ['en' => 'English', 'de' => 'Deutsch', 'fr' => 'Français', 'ru-RU'=>'Русский'],



        'cookieName' => 'language',                         // Name of the cookie.
        'expireDays' => 64,                                 // The expiration time of the cookie is 64 days.
        'callback' => function() {
            if (!\Yii::$app->user->isGuest) {
                $user = \Yii::$app->user->identity;
                $user->language = \Yii::$app->language;
                $user->save();
            }
        }



    ],*/




        'authClientCollection' => [
            'class' => 'yii\authclient\Collection',



            'clients' => [
                // here is the list of clients you want to use
                // you can read more in the "Available clients" section

                'facebook' => [
                    'class'        => 'dektrium\user\clients\Facebook',
                    'clientId'     => 'CLIENT_ID',
                    'clientSecret' => 'CLIENT_SECRET',
                ],
                'twitter' => [
                    'class'          => 'dektrium\user\clients\Twitter',
                    'consumerKey'    => 'CONSUMER_KEY',
                    'consumerSecret' => 'CONSUMER_SECRET',
                ],
                'google' => [
                    'class'        => 'dektrium\user\clients\Google',
                    'clientId'     => 'CLIENT_ID',
                    'clientSecret' => 'CLIENT_SECRET',
                ],

                'github' => [
                    'class'        => 'dektrium\user\clients\GitHub',
                    'clientId'     => 'CLIENT_ID',
                    'clientSecret' => 'CLIENT_SECRET',
                ],


                'vkontakte' => [
                    'class'        => 'dektrium\user\clients\VKontakte',
                    'clientId'     => 'CLIENT_ID',
                    'clientSecret' => 'CLIENT_SECRET',
                ],

                'yandex' => [
                    'class'        => 'dektrium\user\clients\Yandex',
                    'clientId'     => 'CLIENT_ID',
                    'clientSecret' => 'CLIENT_SECRET'
                ],



                //
            ],
        ],
        //End_Auth_registration
],//END_Components


    'modules'=>[

        'user' => [
            'class' => 'dektrium\user\Module',
            'enableUnconfirmedLogin' => true,
            'confirmWithin' => 21600,
            'cost' => 12,
            'admins' => ['admin']
        ],



        'redactor' => [
            'class' => 'yii\redactor\RedactorModule',
            'uploadDir' => '@webroot/path/to/uploadfolder',
            'uploadUrl' => '@web/path/to/uploadfolder',
            'imageAllowExtensions'=>['jpg','png','gif']

        ],                              //END_Yii2-user


        //Admin panel
        'root' => [
            'class' => 'app\modules\root\Module',
        ],


        //GII GENERATED
        //'pages' => [
        //    'class' => 'app\modules\pages\Module',
        //],


        //Модуль страниц https://github.com/bupy7/yii2-pages
        'pages' => [
            'class' => 'app\modules\pages\Module',
            //'tableName' => '{{%your_table_name}}',

            //'tableName' => 'tbl_pages',

            'controllerMap' => [
                'manager' => [
                    'class' => 'app\modules\pages\controllers\ManagerController',
                    'as access' => [
                        'class' =>
                        //AccessControl::className(),//<-- устарело
                            'yii\filters\AccessControl',
                        //'yii\web\AccessControl',
                        'rules' => [
                            [
                                'allow' => true,
                                //'roles' => ['admin'],


                                //Для дебага
                                'roles' => ['@'],
                            ],
                        ],
                    ],
                ],

                //Comments
                //'comments' => 'yii2mod\comments\controllers\ManageController'



            ],


//You can upload and add files/images via Imperavi Redactor, if enable it:
            'pathToImages' => '@webroot/images',
            'urlToImages' => '@web/images',
            'pathToFiles' => '@webroot/files',
            'urlToFiles' => '@web/files',
            'uploadImage' => false,
            'uploadFile' => true,
            'addImage' => true,
            'addFile' => true,
        ],

        'blog' => [
            'class' => 'app\modules\blog\Module',
        ],


        //http://yii2-user.readthedocs.org/en/latest/basics/overriding-controllers.html


        //Подключаю свой вместо user
        /*'user' => [ //mycustomuser
            'class' => 'app\modules\User',

            'class' => 'dektrium\user\Module', //Из документации

            'enableUnconfirmedLogin' => true,
            'confirmWithin' => 21600,
            'cost' => 12,
            'admins' => ['admin']
        ],*/

        //Rat module
        'control' => [
            'class' => 'app\modules\control\Module',
            //'layoutPath' => 'app\modules\control\views\layouts',
            //'layout' => 'main',
        ],


        'gpstracker' => [
            'class' => 'app\modules\gpstracker\Module',
        ],


        //       'comment' => [
        //           'class' => 'yii2mod\comments\Module'
        //       ]




        //Comments module
        //   'comments' => [
        //       'class' => 'vendor\rmrevin\comments\Module',
        //       'userIdentityClass' => 'app\models\User',
        //       'useRbac' => false, //true
        //   ]


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

if (YII_ENV_DEV) { //prod dev test
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
        'allowedIPs' => ['127.0.0.1'],
    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        'allowedIPs' => ['127.0.0.1'],
    ];
}
return $config;

Комментариев нет:

Отправить комментарий