1 | <?php |
||
32 | class BaseSetting extends ActiveRecord implements SettingInterface |
||
33 | { |
||
34 | /** |
||
35 | * @inheritdoc |
||
36 | */ |
||
37 | 18 | public static function tableName() |
|
41 | |||
42 | /** |
||
43 | * @inheritdoc |
||
44 | */ |
||
45 | 4 | public function rules() |
|
46 | { |
||
47 | return [ |
||
48 | 4 | [['value'], 'string'], |
|
49 | 4 | [['section', 'key'], 'string', 'max' => 255], |
|
50 | [ |
||
51 | 4 | ['key'], |
|
52 | 4 | 'unique', |
|
53 | 4 | 'targetAttribute' => ['section', 'key'], |
|
54 | 4 | ], |
|
55 | 4 | ['type', 'in', 'range' => ['string', 'integer', 'boolean', 'float', 'double', 'object', 'null']], |
|
56 | 4 | [['created', 'modified'], 'safe'], |
|
57 | 4 | [['active'], 'boolean'], |
|
58 | 4 | ]; |
|
59 | } |
||
60 | |||
61 | 17 | public function afterSave($insert, $changedAttributes) |
|
62 | { |
||
63 | 17 | parent::afterSave($insert, $changedAttributes); |
|
64 | 17 | Yii::$app->settings->clearCache(); |
|
65 | 17 | } |
|
66 | |||
67 | 4 | public function afterDelete() |
|
68 | { |
||
69 | 4 | parent::afterDelete(); |
|
70 | 4 | Yii::$app->settings->clearCache(); |
|
71 | 4 | } |
|
72 | |||
73 | /** |
||
74 | * @return array |
||
75 | */ |
||
76 | 18 | public function behaviors() |
|
89 | |||
90 | /** |
||
91 | * @inheritdoc |
||
92 | */ |
||
93 | 2 | public function getSettings() |
|
101 | |||
102 | /** |
||
103 | * @inheritdoc |
||
104 | */ |
||
105 | 2 | public function setSetting($section, $key, $value, $type = null) |
|
137 | |||
138 | /** |
||
139 | * @inheritdoc |
||
140 | */ |
||
141 | 4 | public function activateSetting($section, $key) |
|
151 | |||
152 | /** |
||
153 | * @inheritdoc |
||
154 | */ |
||
155 | 2 | public function deactivateSetting($section, $key) |
|
165 | |||
166 | /** |
||
167 | * @inheritdoc |
||
168 | */ |
||
169 | 2 | public function deleteSetting($section, $key) |
|
178 | |||
179 | /** |
||
180 | * @inheritdoc |
||
181 | */ |
||
182 | 2 | public function deleteAllSettings() |
|
186 | |||
187 | /** |
||
188 | * @inheritdoc |
||
189 | */ |
||
190 | 2 | public function findSetting($key, $section = null) |
|
203 | } |
||
204 |