/
Bootstrap.php
112 lines (105 loc) · 3.43 KB
/
Bootstrap.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
namespace giantbits\crelish;
use giantbits\crelish\components\CrelishI18nEventHandler;
use \yii\base\BootstrapInterface;
class Bootstrap implements BootstrapInterface
{
/** @param \yii\web\Application $app */
public function bootstrap($app)
{
if ($app instanceof \yii\web\Application) {
\Yii::$app->setComponents([
'user' => [
'class' => 'yii\web\User',
'identityClass' => 'giantbits\crelish\components\CrelishUser',
'enableAutoLogin' => TRUE,
'loginUrl' => ['crelish/user/login']
],
'defaultRoute' => 'frontend/index',
'view' => [
'class' => 'yii\web\View',
'renderers' => [
'twig' => [
'class' => 'yii\twig\ViewRenderer',
'cachePath' => '@runtime/Twig/cache',
//'extensions' => ['\Twig_Extension_Debug'],
'options' => [
'auto_reload' => TRUE,
],
'globals' => [
'html' => ['class' => '\yii\helpers\Html']
],
'functions' => array(
't' => 'Yii::t',
)
]
]
],
'urlManager' => [
'class' => 'yii\web\UrlManager',
'enablePrettyUrl' => TRUE,
'showScriptName' => FALSE,
'enableStrictParsing' => TRUE,
'suffix' => '.html',
'rules' => [],
],
'i18n' => [
'class' => 'yii\i18n\I18N',
'translations' => [
'crelish*' => [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => '@app/messages',
'sourceLanguage' => 'en-US',
'fileMap' => [
'app' => 'app.php',
'app.error' => 'error.php',
'crelish' => 'crelish.php'
],
'on missingTranslation' => [
CrelishI18nEventHandler::class,
'handleMissingTranslation'
]
],
],
]
]);
$app->getUrlManager()->addRules([
[
'class' => 'yii\web\UrlRule',
'pattern' => 'crelish',
'route' => 'crelish/dahboard/index'
],
[
'class' => 'yii\web\UrlRule',
'pattern' => 'crelish/<controller:[\w\-]+>/<action:[\w\-]+>',
'route' => 'crelish/<controller>/<action>'
],
[
'class' => 'yii\web\UrlRule',
'pattern' => 'site/<action:[\w\-]+>',
'route' => 'site/<action>'
],
[
'class' => 'yii\web\UrlRule',
'pattern' => 'data/<action:[\w\-]+>',
'route' => 'data/<action>'
],
['class' => 'giantbits\crelish\components\CrelishBaseUrlRule'],
[
'class' => 'yii\web\UrlRule',
'pattern' => '<controller:[\w\-]+>/<action:[\w\-]+>',
'route' => '/<controller>/<action>'
],
//['class' => 'yii\web\UrlRule', 'pattern' => '<lang:[\w\-]+]>/<controller:[\w\-]+>/<action:[\w\-]+>', 'route' => '/<controller>/<action>']
], TRUE);
}
// Register crelish.
\Yii::$app->setModules([
'crelish' => [
'class' => 'giantbits\crelish\Module',
'theme' => \Yii::$app->params['crelish']['theme']
],
'redactor' => 'yii\redactor\RedactorModule'
]);
}
}