1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace luya\base; |
4
|
|
|
|
5
|
|
|
use yii\base\BaseObject; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Represents a package config item from the PackageInstaller. |
9
|
|
|
* |
10
|
|
|
* @property array $themes |
11
|
|
|
* @property array $bootstrap |
12
|
|
|
* @property array $blocks |
13
|
|
|
* @property string $package |
14
|
|
|
* |
15
|
|
|
* @author Basil Suter <[email protected]> |
16
|
|
|
* @since 1.0.0 |
17
|
|
|
*/ |
18
|
|
|
class PackageConfig extends BaseObject |
19
|
|
|
{ |
20
|
|
|
private $_values = []; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* Setter method for the values. |
24
|
|
|
* |
25
|
|
|
* @param array $data |
26
|
|
|
* @since 1.0.21 |
27
|
|
|
*/ |
28
|
|
|
public function setValues(array $data) |
29
|
|
|
{ |
30
|
|
|
$this->_values = $data; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Set only a given value for a given key. |
35
|
|
|
* |
36
|
|
|
* @param string $key |
37
|
|
|
* @param mixed $value |
38
|
|
|
* @since 1.0.21 |
39
|
|
|
*/ |
40
|
|
|
public function setValue($key, $value) |
41
|
|
|
{ |
42
|
|
|
$this->_values[$key] = $value; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Get a certain value by key |
47
|
|
|
* |
48
|
|
|
* @param string $key |
49
|
|
|
* @param mixed $default |
50
|
|
|
* @return mixed |
51
|
|
|
* @since 1.0.21 |
52
|
|
|
*/ |
53
|
|
|
public function getValue($key, $default = null) |
54
|
|
|
{ |
55
|
|
|
return array_key_exists($key, $this->_values) ? $this->_values[$key] : $default; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Getter method for bootstrap |
60
|
|
|
* |
61
|
|
|
* Example content: |
62
|
|
|
* |
63
|
|
|
* ```php |
64
|
|
|
* return [ |
65
|
|
|
* 0 => '\\luya\\admin\\Bootstrap', |
66
|
|
|
* ] |
67
|
|
|
* ``` |
68
|
|
|
* |
69
|
|
|
* @return array An array with bootstrap classes. |
70
|
|
|
* @since 1.0.21 |
71
|
|
|
*/ |
72
|
|
|
public function getBootstrap() |
73
|
|
|
{ |
74
|
|
|
return $this->getValue('bootstrap', []); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Getter method for blocks |
79
|
|
|
* |
80
|
|
|
* Example content: |
81
|
|
|
* |
82
|
|
|
* ```php |
83
|
|
|
* return [ |
84
|
|
|
* 0 => 'vendor/luyadev/luya-module-cms/src/frontend/blocks', |
85
|
|
|
* ] |
86
|
|
|
* ``` |
87
|
|
|
* |
88
|
|
|
* @return array An array with block defintions. |
89
|
|
|
* @since 1.0.21 |
90
|
|
|
*/ |
91
|
|
|
public function getBlocks() |
92
|
|
|
{ |
93
|
|
|
return $this->getValue('blocks', []); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Getter method for package |
98
|
|
|
* |
99
|
|
|
* Example content: |
100
|
|
|
* |
101
|
|
|
* ```php |
102
|
|
|
* return [ |
103
|
|
|
* 'name' => 'luyadev/luya-module-admin', |
104
|
|
|
* 'prettyName' => 'luyadev/luya-module-admin', |
105
|
|
|
* 'version' => '2.0.3.0', |
106
|
|
|
* 'targetDir' => NULL, |
107
|
|
|
* 'installSource' => 'dist', |
108
|
|
|
* 'sourceUrl' => 'https://github.com/luyadev/luya-module-admin.git', |
109
|
|
|
* 'packageFolder' => 'luyadev/luya-module-admin', |
110
|
|
|
* ] |
111
|
|
|
* ``` |
112
|
|
|
* |
113
|
|
|
* @return array An array with all informations about the package. |
114
|
|
|
* @since 1.0.21 |
115
|
|
|
*/ |
116
|
|
|
public function getPackage() |
117
|
|
|
{ |
118
|
|
|
return $this->getValue('package', []); |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Getter method for themes |
123
|
|
|
* @var array |
124
|
|
|
* @since 1.0.21 |
125
|
|
|
*/ |
126
|
|
|
public function getThemes() |
127
|
|
|
{ |
128
|
|
|
return $this->getValue('themes', []); |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|