|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace app\backgroundtasks\models; |
|
4
|
|
|
|
|
5
|
|
|
use app; |
|
6
|
|
|
use app\modules\config\models\BaseConfigurationModel; |
|
7
|
|
|
|
|
8
|
|
|
/** |
|
9
|
|
|
* Class ConfigConfigurationModel represents configuration model for retrieving user input |
|
10
|
|
|
* in backend configuration subsystem. |
|
11
|
|
|
* |
|
12
|
|
|
* @package app\backgroundtasks\models |
|
13
|
|
|
*/ |
|
14
|
|
|
class ConfigConfigurationModel extends BaseConfigurationModel |
|
15
|
|
|
{ |
|
16
|
|
|
public $daysToStoreNotify = 28; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @inheritdoc |
|
20
|
|
|
*/ |
|
21
|
|
|
public function rules() |
|
22
|
|
|
{ |
|
23
|
|
|
return [ |
|
24
|
|
|
[['daysToStoreNotify'], 'integer', 'min' => 1], |
|
25
|
|
|
]; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* @inheritdoc |
|
30
|
|
|
*/ |
|
31
|
|
|
public function attributeLabels() |
|
32
|
|
|
{ |
|
33
|
|
|
return [ |
|
34
|
|
|
]; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @inheritdoc |
|
39
|
|
|
*/ |
|
40
|
|
|
public function defaultValues() |
|
41
|
|
|
{ |
|
42
|
|
|
/** @var app\modules\shop\ShopModule $module */ |
|
43
|
|
|
$module = $this->getModuleInstance(); |
|
44
|
|
|
|
|
45
|
|
|
$attributes = array_keys($this->getAttributes()); |
|
46
|
|
|
foreach ($attributes as $attribute) { |
|
47
|
|
|
$this->{$attribute} = $module->{$attribute}; |
|
48
|
|
|
} |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Returns array of module configuration that should be stored in application config. |
|
53
|
|
|
* Array should be ready to merge in app config. |
|
54
|
|
|
* Used both for web only. |
|
55
|
|
|
* |
|
56
|
|
|
* @return array |
|
|
|
|
|
|
57
|
|
|
*/ |
|
58
|
|
|
public function webApplicationAttributes() |
|
59
|
|
|
{ |
|
60
|
|
|
$attributes = $this->getAttributes(); |
|
61
|
|
|
return [ |
|
62
|
|
|
'modules' => [ |
|
63
|
|
|
'background' => $attributes, |
|
64
|
|
|
], |
|
65
|
|
|
]; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Returns array of module configuration that should be stored in application config. |
|
70
|
|
|
* Array should be ready to merge in app config. |
|
71
|
|
|
* Used both for console only. |
|
72
|
|
|
* |
|
73
|
|
|
* @return array |
|
|
|
|
|
|
74
|
|
|
*/ |
|
75
|
|
|
public function consoleApplicationAttributes() |
|
76
|
|
|
{ |
|
77
|
|
|
return [ |
|
78
|
|
|
'modules' => [ |
|
79
|
|
|
'background' => [ |
|
80
|
|
|
'daysToStoreNotify' => $this->daysToStoreNotify, |
|
81
|
|
|
] |
|
82
|
|
|
] |
|
83
|
|
|
]; |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Returns array of module configuration that should be stored in application config. |
|
88
|
|
|
* Array should be ready to merge in app config. |
|
89
|
|
|
* Used both for web and console. |
|
90
|
|
|
* |
|
91
|
|
|
* @return array |
|
92
|
|
|
*/ |
|
93
|
|
|
public function commonApplicationAttributes() |
|
94
|
|
|
{ |
|
95
|
|
|
return []; |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* Returns array of key=>values for configuration. |
|
100
|
|
|
* |
|
101
|
|
|
* @return mixed |
|
102
|
|
|
*/ |
|
103
|
|
|
public function keyValueAttributes() |
|
104
|
|
|
{ |
|
105
|
|
|
return []; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* Returns array of aliases that should be set in common config |
|
110
|
|
|
* @return array |
|
|
|
|
|
|
111
|
|
|
*/ |
|
112
|
|
|
public function aliases() |
|
113
|
|
|
{ |
|
114
|
|
|
return [ |
|
115
|
|
|
'@shop' => dirname(__FILE__) . '/../', |
|
116
|
|
|
]; |
|
117
|
|
|
} |
|
118
|
|
|
} |
This check looks for the generic type
arrayas a return type and suggests a more specific type. This type is inferred from the actual code.