|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace app\models; |
|
4
|
|
|
|
|
5
|
|
|
use app; |
|
6
|
|
|
use Yii; |
|
7
|
|
|
|
|
8
|
|
|
class BaseThemeConfigurationModel extends app\modules\config\models\BaseConfigurationModel |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* @var bool Should this theme be registered as @theme alias in config |
|
12
|
|
|
*/ |
|
13
|
|
|
public $registerThemeAlias = true; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* Fills model attributes with default values |
|
17
|
|
|
* @return void |
|
18
|
|
|
*/ |
|
19
|
|
|
public function defaultValues() |
|
20
|
|
|
{ |
|
21
|
|
|
return; |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Returns array of module configuration that should be stored in application config. |
|
26
|
|
|
* Array should be ready to merge in app config. |
|
27
|
|
|
* Used both for web only. |
|
28
|
|
|
* |
|
29
|
|
|
* @return array |
|
|
|
|
|
|
30
|
|
|
*/ |
|
31
|
|
|
public function webApplicationAttributes() |
|
32
|
|
|
{ |
|
33
|
|
|
return [ |
|
34
|
|
|
'modules' => [ |
|
35
|
|
|
$this->getModule() => [ |
|
36
|
|
|
'class' => $this->getModuleInstance()->className(), |
|
37
|
|
|
], |
|
38
|
|
|
] |
|
39
|
|
|
]; |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Returns array of module configuration that should be stored in application config. |
|
44
|
|
|
* Array should be ready to merge in app config. |
|
45
|
|
|
* Used both for console only. |
|
46
|
|
|
* |
|
47
|
|
|
* @return array |
|
48
|
|
|
*/ |
|
49
|
|
|
public function consoleApplicationAttributes() |
|
50
|
|
|
{ |
|
51
|
|
|
return []; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Returns array of module configuration that should be stored in application config. |
|
56
|
|
|
* Array should be ready to merge in app config. |
|
57
|
|
|
* Used both for web and console. |
|
58
|
|
|
* |
|
59
|
|
|
* @return array |
|
60
|
|
|
*/ |
|
61
|
|
|
public function commonApplicationAttributes() |
|
62
|
|
|
{ |
|
63
|
|
|
return []; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Returns array of key=>values for configuration. |
|
68
|
|
|
* |
|
69
|
|
|
* @return mixed |
|
70
|
|
|
*/ |
|
71
|
|
|
public function keyValueAttributes() |
|
72
|
|
|
{ |
|
73
|
|
|
return []; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Returns array of aliases that should be set in common config |
|
78
|
|
|
* @return array |
|
79
|
|
|
*/ |
|
80
|
|
View Code Duplication |
public function aliases() |
|
81
|
|
|
{ |
|
82
|
|
|
if ($this->registerThemeAlias === true) { |
|
83
|
|
|
if ($this->getModuleInstance() !== null) { |
|
84
|
|
|
$reflectionClass = new \ReflectionClass($this->getModuleInstance()); |
|
85
|
|
|
return [ |
|
86
|
|
|
'@' . $this->getModule() => dirname($reflectionClass->getFileName()), |
|
87
|
|
|
]; |
|
88
|
|
|
} |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
return []; |
|
92
|
|
|
|
|
93
|
|
|
} |
|
94
|
|
|
} |
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.