Module::init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
namespace graychen\yii2\basic\auth;
3
4
use yii\base\Module as BaseModule;
5
6
/**
7
 * portal module definition class
8
 */
9
class Module extends BaseModule
10
{
11
    /**
12
     * @inheritdoc
13
     */
14
    public $controllerNamespace = 'graychen/yii2/basic/auth/controllers';
15
    /**
16
     *
17
     * @var string source language for translation
18
     */
19
    public $sourceLanguage = 'en-US';
20
    /**
21
     * @inheritdoc
22
     */
23
    public function init()
24
    {
25
        parent::init();
26
        $this->registerTranslations();
27
    }
28
    /**
29
     * Registers the translation files
30
     */
31
    protected function registerTranslations()
32
    {
33
        Yii::$app->i18n->translations['graychen/yii2/basic/auth/*'] = [
0 ignored issues
show
Bug introduced by
The type graychen\yii2\basic\auth\Yii was not found. Did you mean Yii? If so, make sure to prefix the type with \.
Loading history...
34
            'class' => 'yii\i18n\PhpMessageSource',
35
            'sourceLanguage' => $this->sourceLanguage,
36
            'basePath' => '@graychen/yii2/basic/auth/messages',
37
            'fileMap' => [
38
                'graychen/yii2/basic/auth/app.php' => 'app.php',
39
            ],
40
        ];
41
    }
42
    /**
43
     * Translates a message. This is just a wrapper of Yii::t
44
     *
45
     * @see Yii::t
46
     *
47
     * @param $category
48
     * @param $message
49
     * @param array $params
50
     * @param null $language
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $language is correct as it would always require null to be passed?
Loading history...
51
     * @return string
52
     */
53
    public static function t($category, $message, $params = [], $language = null)
54
    {
55
        return Yii::t('graychen/yii2/basic/auth/' . $category, $message, $params, $language);
56
    }
57
}
58