1 | <?php |
||
12 | class FileActivator implements ActivatorInterface |
||
13 | { |
||
14 | /** |
||
15 | * Laravel cache instance |
||
16 | * |
||
17 | * @var CacheManager |
||
18 | */ |
||
19 | private $cache; |
||
20 | |||
21 | /** |
||
22 | * Laravel Filesystem instance |
||
23 | * |
||
24 | * @var Filesystem |
||
25 | */ |
||
26 | private $files; |
||
27 | |||
28 | /** |
||
29 | * Laravel config instance |
||
30 | * |
||
31 | * @var Config |
||
32 | */ |
||
33 | private $config; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | private $cacheKey; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | private $cacheLifetime; |
||
44 | |||
45 | /** |
||
46 | * Array of modules activation statuses |
||
47 | * |
||
48 | * @var array |
||
49 | */ |
||
50 | private $modulesStatuses; |
||
51 | |||
52 | /** |
||
53 | * File used to store activation statuses |
||
54 | * |
||
55 | * @var string |
||
56 | */ |
||
57 | private $statusesFile; |
||
58 | |||
59 | 191 | public function __construct(Container $app) |
|
69 | |||
70 | /** |
||
71 | * Get modules statuses, either from the cache or |
||
72 | * from the json statuses file if the cache is disabled. |
||
73 | * |
||
74 | * @return array |
||
75 | */ |
||
76 | 191 | private function getModulesStatuses() |
|
86 | |||
87 | /** |
||
88 | * Flushes the modules activation statuses cache |
||
89 | */ |
||
90 | 188 | private function flushCache() |
|
94 | |||
95 | /** |
||
96 | * Reads a config parameter |
||
97 | * |
||
98 | * @param string $key [description] |
||
99 | * @param $default |
||
100 | * @return mixed |
||
101 | */ |
||
102 | 191 | private function config(string $key, $default = null) |
|
106 | |||
107 | /** |
||
108 | * Reads the json file that contains the activation statuses. |
||
109 | * |
||
110 | * @return array |
||
111 | */ |
||
112 | 191 | private function readJson() |
|
120 | |||
121 | /** |
||
122 | * Writes the activation statuses in a file, as json |
||
123 | */ |
||
124 | 130 | private function writeJson() |
|
128 | |||
129 | /** |
||
130 | * Get the path of the file where statuses are stored |
||
131 | * |
||
132 | * @return string |
||
133 | */ |
||
134 | 2 | public function getStatusesFilePath() |
|
138 | |||
139 | /** |
||
140 | * @inheritDoc |
||
141 | */ |
||
142 | 98 | public function reset() |
|
150 | |||
151 | /** |
||
152 | * @inheritDoc |
||
153 | */ |
||
154 | 6 | public function enable(Module $module) |
|
158 | |||
159 | /** |
||
160 | * @inheritDoc |
||
161 | */ |
||
162 | 6 | public function disable(Module $module) |
|
166 | |||
167 | /** |
||
168 | * @inheritDoc |
||
169 | */ |
||
170 | 16 | public function isStatus(Module $module, bool $status): bool |
|
178 | |||
179 | /** |
||
180 | * @inheritDoc |
||
181 | */ |
||
182 | 4 | public function setActive(Module $module, bool $active) |
|
186 | |||
187 | /** |
||
188 | * @inheritDoc |
||
189 | */ |
||
190 | 130 | public function setActiveByName(string $name, bool $status) |
|
196 | |||
197 | /** |
||
198 | * @inheritDoc |
||
199 | */ |
||
200 | 2 | public function delete(Module $module) |
|
209 | } |
||
210 |