1 | <?php |
||
14 | class Module_Properties { |
||
15 | const ENABLED = 1; |
||
16 | const DISABLED = 0; |
||
17 | const UNINSTALLED = -1; |
||
18 | /** |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $module_data = []; |
||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $module; |
||
26 | /** |
||
27 | * Creating of object and saving module data inside |
||
28 | * |
||
29 | * @param array $module_data |
||
30 | * @param string $module |
||
31 | */ |
||
32 | 42 | public function __construct ($module_data, $module) { |
|
36 | /** |
||
37 | * Whether module is enabled |
||
38 | * |
||
39 | * @return bool |
||
40 | */ |
||
41 | 2 | public function enabled () { |
|
42 | 2 | return $this->module_data['active'] == self::ENABLED; |
|
43 | } |
||
44 | /** |
||
45 | * Whether module is disabled |
||
46 | * |
||
47 | * @return bool |
||
48 | */ |
||
49 | public function disabled () { |
||
52 | /** |
||
53 | * Whether module is installed |
||
54 | * |
||
55 | * @return bool |
||
56 | */ |
||
57 | public function installed () { |
||
60 | /** |
||
61 | * Whether module is uninstalled |
||
62 | * |
||
63 | * @return bool |
||
64 | */ |
||
65 | public function uninstalled () { |
||
68 | /** |
||
69 | * Get db id by name |
||
70 | * |
||
71 | * @param string $db_name |
||
72 | * |
||
73 | * @return int |
||
74 | */ |
||
75 | 38 | public function db ($db_name) { |
|
78 | /** |
||
79 | * Get storage id by name |
||
80 | * |
||
81 | * @param string $storage_name |
||
82 | * |
||
83 | * @return int |
||
84 | */ |
||
85 | public function storage ($storage_name) { |
||
88 | /** |
||
89 | * Get data item of module configuration |
||
90 | * |
||
91 | * @param string $item |
||
92 | * |
||
93 | * @return false|mixed |
||
94 | */ |
||
95 | public function __get ($item) { |
||
98 | /** |
||
99 | * Set data item of module configuration (only for admin) |
||
100 | * |
||
101 | * @param string $item |
||
102 | * @param mixed $value |
||
103 | */ |
||
104 | public function __set ($item, $value) { |
||
107 | /** |
||
108 | * Get data item (or array of items) of module configuration |
||
109 | * |
||
110 | * @param string|string[] $item |
||
111 | * |
||
112 | * @return false|mixed|mixed[] |
||
113 | */ |
||
114 | public function get ($item) { |
||
127 | /** |
||
128 | * Set data item (or array of items) of module configuration (only for admin) |
||
129 | * |
||
130 | * @param array|string $item |
||
131 | * @param mixed|null $value |
||
132 | * |
||
133 | * @return bool |
||
134 | * |
||
135 | * @throws \cs\ExitException |
||
136 | */ |
||
137 | public function set ($item, $value = null) { |
||
161 | } |
||
162 |