-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBootstrap.php
52 lines (47 loc) · 1.4 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
<?php
/**
* Created by PhpStorm.
* User: singletonn
* Date: 9/19/18
* Time: 5:15 PM
*/
namespace pantera\content;
use Yii;
use yii\base\Application;
use yii\base\BootstrapInterface;
use yii\i18n\PhpMessageSource;
class Bootstrap implements BootstrapInterface
{
/* @var Module|\pantera\content\admin\Module */
public $module;
/**
* Bootstrap method to be called during application bootstrap stage.
* @param Application $app the application currently running
* @throws \yii\base\InvalidConfigException
*/
public function bootstrap($app)
{
$this->module = $app->getModule('content');
if ($this->module) {
if (!isset($app->get('i18n')->translations['content'])) {
$app->get('i18n')->translations['content'] = [
'class' => PhpMessageSource::class,
'basePath' => __DIR__ . '/admin/messages',
'sourceLanguage' => 'en-US'
];
}
if (property_exists($this->module, 'urlRules')) {
$this->addUrlConfig();
}
}
}
protected function addUrlConfig()
{
$configUrlRule = [
'rules' => $this->module->urlRules,
];
$configUrlRule['class'] = 'yii\web\GroupUrlRule';
$rule = Yii::createObject($configUrlRule);
Yii::$app->urlManager->addRules([$rule], false);
}
}