-
Notifications
You must be signed in to change notification settings - Fork 74
/
Module.php
executable file
·73 lines (64 loc) · 1.7 KB
/
Module.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
<?php
/**
* @link http://phe.me
* @copyright Copyright (c) 2014 Pheme
* @license MIT http://opensource.org/licenses/MIT
*/
namespace pheme\settings;
use Yii;
/**
* @author Aris Karageorgos <[email protected]>
*/
class Module extends \yii\base\Module
{
/**
* @var string The controller namespace to use
*/
public $controllerNamespace = 'pheme\settings\controllers';
/**
*
* @var string source language for translation
*/
public $sourceLanguage = 'en-US';
/**
* @var null|array The roles which have access to module controllers, eg. ['admin']. If set to `null`, there is no accessFilter applied
*/
public $accessRoles = null;
/**
* Init module
*/
public function init()
{
parent::init();
$this->registerTranslations();
}
/**
* Registers the translation files
*/
protected function registerTranslations()
{
Yii::$app->i18n->translations['extensions/yii2-settings/*'] = [
'class' => 'yii\i18n\PhpMessageSource',
'sourceLanguage' => $this->sourceLanguage,
'basePath' => '@vendor/pheme/yii2-settings/messages',
'fileMap' => [
'extensions/yii2-settings/settings' => 'settings.php',
],
];
}
/**
* Translates a message. This is just a wrapper of Yii::t
*
* @see Yii::t
*
* @param $category
* @param $message
* @param array $params
* @param null $language
* @return string
*/
public static function t($category, $message, $params = [], $language = null)
{
return Yii::t('extensions/yii2-settings/' . $category, $message, $params, $language);
}
}