1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @link http://phe.me |
5
|
|
|
* @copyright Copyright (c) 2014 Pheme |
6
|
|
|
* @license MIT http://opensource.org/licenses/MIT |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace pheme\settings; |
10
|
|
|
|
11
|
|
|
use Yii; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* @author Aris Karageorgos <[email protected]> |
15
|
|
|
*/ |
16
|
|
|
class Module extends \yii\base\Module |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* @var string The controller namespace to use |
20
|
|
|
*/ |
21
|
|
|
public $controllerNamespace = 'pheme\settings\controllers'; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* |
25
|
|
|
* @var string source language for translation |
26
|
|
|
*/ |
27
|
|
|
public $sourceLanguage = 'en-US'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var null|array The roles which have access to module controllers, eg. ['admin']. If set to `null`, there is no accessFilter applied |
31
|
|
|
*/ |
32
|
|
|
public $accessRoles = null; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Init module |
36
|
|
|
*/ |
37
|
|
|
public function init() |
38
|
|
|
{ |
39
|
|
|
parent::init(); |
40
|
|
|
$this->registerTranslations(); |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* Registers the translation files |
45
|
|
|
*/ |
46
|
|
|
protected function registerTranslations() |
47
|
|
|
{ |
48
|
|
|
Yii::$app->i18n->translations['extensions/yii2-settings/*'] = [ |
49
|
|
|
'class' => 'yii\i18n\PhpMessageSource', |
50
|
|
|
'sourceLanguage' => $this->sourceLanguage, |
51
|
|
|
'basePath' => '@vendor/pheme/yii2-settings/messages', |
52
|
|
|
'fileMap' => [ |
53
|
|
|
'extensions/yii2-settings/settings' => 'settings.php', |
54
|
|
|
], |
55
|
|
|
]; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Translates a message. This is just a wrapper of Yii::t |
60
|
|
|
* |
61
|
|
|
* @see Yii::t |
62
|
|
|
* |
63
|
|
|
* @param $category |
64
|
|
|
* @param $message |
65
|
|
|
* @param array $params |
66
|
|
|
* @param null $language |
67
|
|
|
* @return string |
68
|
|
|
*/ |
69
|
|
|
public static function t($category, $message, $params = [], $language = null) |
70
|
|
|
{ |
71
|
|
|
return Yii::t('extensions/yii2-settings/' . $category, $message, $params, $language); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|