Completed
Push — master ( 98677a...347b91 )
by
unknown
01:26
created

ConfigureForm   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 50
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A rules() 0 6 1
A attributeLabels() 0 6 1
A attributeHints() 0 6 1
A loadSettings() 0 6 1
A save() 0 6 1
1
<?php
2
3
namespace humhub\modules\discordapp\models;
4
5
use Yii;
6
use yii\base\Model;
7
8
/**
9
 * ConfigureForm defines the configurable fields.
10
 */
11
class ConfigureForm extends Model
12
{
13
14
    public $serverUrl;
15
16
    /**
17
     * @inheritdoc
18
     */
19
    public function rules()
20
    {
21
        return [
22
            ['serverUrl', 'string'],
23
        ];
24
    }
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function attributeLabels()
30
    {
31
        return [
32
            'serverUrl' => Yii::t('DiscordappModule.base', 'Discord Widget URL:'),
33
        ];
34
    }
35
36
    /**
37
     * @inheritdoc
38
     */
39
    public function attributeHints()
40
    {
41
        return [
42
            'serverUrl' => Yii::t('DiscordappModule.base', 'e.g. https://discordapp.com/widget?id={server-id} or https://discordapp.com/widget?id={server-id}&theme=dark'),
43
        ];
44
    }
45
46
    public function loadSettings()
47
    {
48
        $this->serverUrl = Yii::$app->getModule('discordapp')->settings->get('serverUrl');
49
50
        return true;
51
    }
52
53
    public function save()
54
    {
55
        Yii::$app->getModule('discordapp')->settings->set('serverUrl', $this->serverUrl);
56
57
        return true;
58
    }
59
60
}
61