コード例 #1
0
 public function behaviors()
 {
     return ArrayHelper::merge(parent::behaviors(), ['access' => ['rules' => [['allow' => true, 'actions' => ['captcha'], 'roles' => ['?', '@']]]]]);
 }
コード例 #2
0
ファイル: main.php プロジェクト: tqsq2005/Yii2adv
<?php

$config = ['sourceLanguage' => 'en-US', 'bootstrap' => ['log'], 'timeZone' => 'Asia/Shanghai', 'language' => 'zh-CN', 'vendorPath' => dirname(dirname(__DIR__)) . '/vendor', 'modules' => ['user' => ['class' => 'dektrium\\user\\Module', 'admins' => ['jsadmin', 'sa'], 'enableFlashMessages' => false, 'controllerMap' => ['registration' => ['class' => \dektrium\user\controllers\RegistrationController::className(), 'on ' . \dektrium\user\models\User::AFTER_REGISTER => function ($e) {
    Yii::$app->response->redirect(array('/user/security/login'))->send();
    Yii::$app->end();
}]]], 'treemanager' => ['class' => '\\kartik\\tree\\Module'], 'gridview' => ['class' => 'kartik\\grid\\Module'], 'dynagrid' => ['class' => '\\kartik\\dynagrid\\Module', 'dbSettings' => ['tableName' => 'populac_dynagrid'], 'dbSettingsDtl' => ['tableName' => 'populac_dynagrid_dtl']], 'datecontrol' => ['class' => 'kartik\\datecontrol\\Module', 'displaySettings' => ['date' => 'Y-m-d', 'time' => 'H:i:s', 'datetime' => 'Y-m-d H:i:s'], 'saveSettings' => ['date' => 'Y-m-d', 'time' => 'H:i:s', 'datetime' => 'Y-m-d H:i:s'], 'autoWidget' => true]], 'components' => ['cache' => ['class' => 'yii\\caching\\FileCache'], 'db' => ['class' => 'yii\\db\\Connection', 'dsn' => 'mysql:host=localhost;dbname=populac_adv', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'tablePrefix' => 'populac_'], 'mailer' => ['class' => 'yii\\swiftmailer\\Mailer', 'viewPath' => '@common/mail', 'useFileTransport' => false, 'transport' => ['class' => 'Swift_SmtpTransport', 'host' => 'smtp.163.com', 'username' => '*****@*****.**', 'password' => 'owybvyotjrnxfvlu', 'port' => '25', 'encryption' => 'tls'], 'messageConfig' => ['from' => ['*****@*****.**' => 'Admin'], 'charset' => 'UTF-8']], 'formatter' => ['dateFormat' => 'php:Y.m.d', 'datetimeFormat' => 'php:Y.m.d H:i:s', 'timeFormat' => 'php:H:i:s', 'defaultTimeZone' => 'Asia/Shanghai'], 'authManager' => ['class' => 'yii\\rbac\\DbManager'], 'settings' => ['class' => 'pheme\\settings\\components\\Settings'], 'view' => ['theme' => ['pathMap' => ['@dektrium/user/views' => '@common/views/user', '@bedezign/yii2/audit/views' => '@common/views/audit']]], 'assetManager' => ['bundles' => ['yii\\jui\\JuiAsset' => ['css' => ['themes/cupertino/jquery-ui.css']], 'nullref\\datatable\\DataTableAsset' => ['styling' => \nullref\datatable\DataTableAsset::STYLING_JUI]]], 'urlManager' => ['rules' => ['populac/<controller:[a-zA-Z0-9_\\-]+>-list' => 'populac/<controller>/index', 'populac/<module:[a-zA-Z0-9_\\-]+>/<controller:[a-zA-Z0-9_\\-]+>-list' => 'populac/<module>/<controller>/index', 'populac/<controller:[a-zA-Z0-9_\\-]+>/<action:[\\w-]+>/<id:\\d+>' => 'populac/<controller>/<action>', 'populac/<module:[a-zA-Z0-9_\\-]+>/<controller:[a-zA-Z0-9_\\-]+>/<action:[\\w-]+>/<id:\\d+>' => 'populac/<module>/<controller>/<action>']], 'i18n' => ['translations' => ['easyii' => ['class' => 'yii\\i18n\\PhpMessageSource', 'sourceLanguage' => 'en-US', 'basePath' => '@common/messages', 'fileMap' => ['easyii' => 'easyii.php']], 'yii2tech-admin' => ['class' => 'yii\\i18n\\PhpMessageSource', 'sourceLanguage' => 'en-US', 'basePath' => '@common/messages', 'fileMap' => ['yii2tech-admin' => 'yii2tech-admin.php']], 'user' => ['class' => 'yii\\i18n\\PhpMessageSource', 'sourceLanguage' => 'en-US', 'basePath' => '@common/messages', 'fileMap' => ['user' => 'user.php']], 'audit' => ['class' => 'yii\\i18n\\PhpMessageSource', 'sourceLanguage' => 'en-US', 'basePath' => '@common/messages', 'fileMap' => ['audit' => 'audit.php']]]]]];
//调试模式启用debug及gii
if (!YII_ENV_TEST) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    //$config['modules']['debug'] = 'yii\debug\Module';
    $config['modules']['debug'] = ['class' => 'yii\\debug\\Module', 'allowedIPs' => ['127.0.0.1', '::1', '192.168.*']];
    $config['bootstrap'][] = 'gii';
    //$config['modules']['gii'] = 'yii\gii\Module';
    $config['modules']['gii'] = ['class' => 'yii\\gii\\Module', 'generators' => ['sintret' => ['class' => 'sintret\\gii\\generators\\crud\\Generator'], 'sintretModel' => ['class' => 'sintret\\gii\\generators\\model\\Generator'], 'kartikgii-crud' => ['class' => 'warrence\\kartikgii\\crud\\Generator'], 'crud' => ['class' => 'yii\\gii\\generators\\crud\\Generator', 'templates' => ['default' => '@common/components/gii/crud/default']], 'adminMainFrame' => ['class' => 'yii2tech\\admin\\gii\\mainframe\\Generator'], 'adminCrud' => ['class' => 'yii2tech\\admin\\gii\\crud\\Generator'], 'materializecss' => ['class' => 'yii\\gii\\generators\\crud\\Generator', 'templates' => ['materializecss' => '@vendor/macgyer/yii2-materializecss/src/gii-templates/generators/crud/materializecss']]], 'allowedIPs' => ['127.0.0.1', '::1', '192.168.*']];
}
return $config;
コード例 #3
0
 public function init()
 {
     parent::init();
 }