-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathBootstrap.php
53 lines (49 loc) · 1.73 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
<?php
/*
* This file is part of the simple cms project for Yii2
*
* (c) Schallschlucker Agency Paul Kerspe - project homepage <https://github.com/pkerspe/yii2-simple-cms>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace schallschlucker\simplecms;
use yii\base\BootstrapInterface;
use yii\web\GroupUrlRule;
/**
* Bootstrap class registers module and url rules which will be applied
* when UrlManager.enablePrettyUrl is enabled.
*
*/
class Bootstrap implements BootstrapInterface
{
/**
* @inheritdoc
*/
public function bootstrap($app)
{
if ($app->hasModule('simplecms_frontend')) {
// if (!$app->hasModule('simplecms_frontend')) {
// $app->setModule('simplecms_frontend', [
// 'class' => 'schallschlucker\simplecms\Frontend'
// ]);
// }
/** @var $module Module */
$module = $app->getModule('simplecms_frontend');
if($module == null)
throw new \Exception("Could not find module simplecms_frontend. Please make sure it is configured in your main configuration");
if (!$app instanceof \yii\console\Application) {
$configUrlRule = [
'prefix' => $module->urlPrefix,
'routePrefix' => $module->routePrefix,
'rules' => $module->urlRules
];
$app->get('urlManager')->rules[] = new GroupUrlRule($configUrlRule);
}
$app->get('i18n')->translations['simplecms*'] = [
'class' => 'yii\i18n\PhpMessageSource',
'basePath' => __DIR__ . '/messages',
];
}
}
}