1
|
|
|
<?php |
|
|
|
|
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* HiPanel core package |
5
|
|
|
* |
6
|
|
|
* @link https://hipanel.com/ |
7
|
|
|
* @package hipanel-core |
8
|
|
|
* @license BSD-3-Clause |
9
|
|
|
* @copyright Copyright (c) 2014-2016, HiQDev (http://hiqdev.com/) |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
use yii\helpers\ArrayHelper; |
13
|
|
|
|
14
|
|
|
function d($a) |
15
|
|
|
{ |
16
|
|
|
echo '<pre>'; |
17
|
|
|
var_dump($a); |
|
|
|
|
18
|
|
|
debug_print_backtrace(0, 3); |
19
|
|
|
die(); |
|
|
|
|
20
|
|
|
} |
21
|
|
|
|
22
|
|
|
$params = array_merge( |
23
|
|
|
require(Yii::getAlias('@hipanel/common/config/params.php')), |
24
|
|
|
require(Yii::getAlias('@project/common/config/params.php')), |
25
|
|
|
require(Yii::getAlias('@project/common/config/params-local.php')) |
26
|
|
|
); |
27
|
|
|
|
28
|
|
|
/// Overrides default values for 3rd part modules |
29
|
|
|
Yii::$container->set('kartik\widgets\DatePicker', function ($container, $params, $config) { |
30
|
|
|
return new \kartik\widgets\DatePicker(ArrayHelper::merge([ |
31
|
|
|
'separator' => Yii::t('app', '← between →'), |
32
|
|
|
], $config)); |
33
|
|
|
}); |
34
|
|
|
|
35
|
|
|
Yii::$container->set('kartik\date\DatePicker', function ($container, $params, $config) { |
36
|
|
|
return new \kartik\date\DatePicker(ArrayHelper::merge([ |
37
|
|
|
'separator' => Yii::t('app', '← between →'), |
38
|
|
|
], $config)); |
39
|
|
|
}); |
40
|
|
|
|
41
|
|
|
Yii::$container->set('kartik\field\FieldRange', function ($container, $params, $config) { |
42
|
|
|
return new \kartik\field\FieldRange(ArrayHelper::merge([ |
43
|
|
|
'separator' => Yii::t('app', '← between →'), |
44
|
|
|
], $config)); |
45
|
|
|
}); |
46
|
|
|
|
47
|
|
|
$config = [ |
48
|
|
|
'vendorPath' => '@project/vendor', |
49
|
|
|
'aliases' => [ |
50
|
|
|
'bower' => '@vendor/bower-asset', |
51
|
|
|
'npm' => '@vendor/npm-asset', |
52
|
|
|
], |
53
|
|
|
'components' => [ |
54
|
|
|
'cache' => [ |
55
|
|
|
'class' => 'hipanel\base\Cache', |
56
|
|
|
// 'cache' => 'yii\caching\FileCache', |
|
|
|
|
57
|
|
|
], |
58
|
|
|
'authManager' => [ |
59
|
|
|
'class' => 'hipanel\base\AuthManager', |
60
|
|
|
], |
61
|
|
|
'hiresource' => [ |
62
|
|
|
'class' => 'hipanel\base\Connection', |
63
|
|
|
'auth' => function () { |
64
|
|
|
if (Yii::$app->user->identity) { |
65
|
|
|
return ['access_token' => Yii::$app->user->identity->getAccessToken()]; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
if (Yii::$app->user->loginRequired() !== null) { |
69
|
|
|
Yii::trace('Login is required. Redirecting to the login page', 'hipanel'); |
70
|
|
|
Yii::$app->response->send(); |
71
|
|
|
Yii::$app->end(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
return []; |
75
|
|
|
}, |
76
|
|
|
'config' => [ |
77
|
|
|
'api_url' => $params['api_url'], |
78
|
|
|
'base_uri' => $params['api_url'], |
79
|
|
|
], |
80
|
|
|
], |
81
|
|
|
'mailer' => [ |
82
|
|
|
'class' => 'yii\swiftmailer\Mailer', |
83
|
|
|
'viewPath' => '@common/mail', |
84
|
|
|
// send all mails to a file by default. You have to set |
85
|
|
|
// 'useFileTransport' to false and configure a transport |
86
|
|
|
// for the mailer to send real emails. |
87
|
|
|
'useFileTransport' => true, |
88
|
|
|
], |
89
|
|
|
'i18n' => [ |
90
|
|
|
'class' => \hipanel\base\I18N::class, |
91
|
|
|
], |
92
|
|
|
], |
93
|
|
|
]; |
94
|
|
|
|
95
|
|
|
if (YII_DEBUG && !YII_ENV_TEST) { |
96
|
|
|
// configuration adjustments for 'dev' environment |
97
|
|
|
$config['bootstrap']['debug'] = 'debug'; |
98
|
|
|
$config['modules']['debug'] = [ |
99
|
|
|
'class' => 'yii\debug\Module', |
100
|
|
|
'allowedIPs' => isset($params['debug_ips']) ? $params['debug_ips'] : '', |
101
|
|
|
'panels' => [ |
102
|
|
|
'hiresource' => [ |
103
|
|
|
'class' => 'hiqdev\hiart\DebugPanel', |
104
|
|
|
], |
105
|
|
|
], |
106
|
|
|
]; |
107
|
|
|
|
108
|
|
|
$config['bootstrap']['gii'] = 'gii'; |
109
|
|
|
$config['modules']['gii'] = 'yii\gii\Module'; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
return $config; |
113
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.