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
|
|
|
* Get a certain value by key |
35
|
|
|
* |
36
|
|
|
* @param string $key |
37
|
|
|
* @param mixed $default |
38
|
|
|
* @return mixed |
39
|
|
|
* @since 1.0.21 |
40
|
|
|
*/ |
41
|
|
|
public function getValue($key, $default = null) |
42
|
|
|
{ |
43
|
|
|
return array_key_exists($key, $this->_values) ? $this->_values[$key] : $default; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Getter method for bootstrap |
48
|
|
|
* |
49
|
|
|
* Example content: |
50
|
|
|
* |
51
|
|
|
* ```php |
52
|
|
|
* return [ |
53
|
|
|
* 0 => '\\luya\\admin\\Bootstrap', |
54
|
|
|
* ] |
55
|
|
|
* ``` |
56
|
|
|
* |
57
|
|
|
* @return array An array with bootstrap classes. |
58
|
|
|
* @since 1.0.21 |
59
|
|
|
*/ |
60
|
|
|
public function getBootstrap() |
61
|
|
|
{ |
62
|
|
|
return $this->getValue('bootstrap', []); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Getter method for blocks |
67
|
|
|
* |
68
|
|
|
* Example content: |
69
|
|
|
* |
70
|
|
|
* ```php |
71
|
|
|
* return [ |
72
|
|
|
* 0 => 'vendor/luyadev/luya-module-cms/src/frontend/blocks', |
73
|
|
|
* ] |
74
|
|
|
* ``` |
75
|
|
|
* |
76
|
|
|
* @return array An array with block defintions. |
77
|
|
|
* @since 1.0.21 |
78
|
|
|
*/ |
79
|
|
|
public function getBlocks() |
80
|
|
|
{ |
81
|
|
|
return $this->getValue('blocks', []); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* Getter method for package |
86
|
|
|
* |
87
|
|
|
* Example content: |
88
|
|
|
* |
89
|
|
|
* ```php |
90
|
|
|
* return [ |
91
|
|
|
* 'name' => 'luyadev/luya-module-admin', |
92
|
|
|
* 'prettyName' => 'luyadev/luya-module-admin', |
93
|
|
|
* 'version' => '2.0.3.0', |
94
|
|
|
* 'targetDir' => NULL, |
95
|
|
|
* 'installSource' => 'dist', |
96
|
|
|
* 'sourceUrl' => 'https://github.com/luyadev/luya-module-admin.git', |
97
|
|
|
* 'packageFolder' => 'luyadev/luya-module-admin', |
98
|
|
|
* ] |
99
|
|
|
* ``` |
100
|
|
|
* |
101
|
|
|
* @return array An array with all informations about the package. |
102
|
|
|
* @since 1.0.21 |
103
|
|
|
*/ |
104
|
|
|
public function getPackage() |
105
|
|
|
{ |
106
|
|
|
return $this->getValue('package', []); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Getter method for themes |
111
|
|
|
* @var array |
112
|
|
|
* @since 1.0.21 |
113
|
|
|
*/ |
114
|
|
|
public function getThemes() |
115
|
|
|
{ |
116
|
|
|
return $this->getValue('themes', []); |
117
|
|
|
} |
118
|
|
|
} |
119
|
|
|
|