1 | <?php |
||
12 | class FileActivator implements ActivatorInterface |
||
13 | { |
||
14 | /** |
||
15 | * Laravel cache instance |
||
16 | * |
||
17 | * @var CacheManager |
||
18 | */ |
||
19 | protected $cache; |
||
20 | |||
21 | /** |
||
22 | * Laravel Filesystem instance |
||
23 | * |
||
24 | * @var Filesystem |
||
25 | */ |
||
26 | protected $files; |
||
27 | |||
28 | /** |
||
29 | * Laravel config instance |
||
30 | * |
||
31 | * @var Config |
||
32 | */ |
||
33 | protected $config; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $cacheKey; |
||
39 | |||
40 | /** |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $cacheLifetime; |
||
44 | |||
45 | /** |
||
46 | * Array of modules activation statuses |
||
47 | * |
||
48 | * @var array |
||
49 | */ |
||
50 | protected $modulesStatuses; |
||
51 | |||
52 | /** |
||
53 | * File used to store activation statuses |
||
54 | * |
||
55 | * @var string |
||
56 | */ |
||
57 | protected $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() |
|
84 | |||
85 | /** |
||
86 | * Flushes the modules activation statuses cache |
||
87 | */ |
||
88 | 188 | private function flushCache() |
|
92 | |||
93 | /** |
||
94 | * Reads a config parameter |
||
95 | * |
||
96 | * @param string $key [description] |
||
97 | * @param $default |
||
98 | * @return mixed |
||
99 | */ |
||
100 | 191 | private function config(string $key, $default = null) |
|
104 | |||
105 | /** |
||
106 | * Reads the json file that contains the activation statuses. |
||
107 | * |
||
108 | * @return array |
||
109 | */ |
||
110 | 191 | private function readJson() |
|
115 | |||
116 | /** |
||
117 | * Writes the activation statuses in a file, as json |
||
118 | */ |
||
119 | 130 | private function writeJson() |
|
123 | |||
124 | /** |
||
125 | * Get the path of the file where statuses are stored |
||
126 | * |
||
127 | * @return string |
||
128 | */ |
||
129 | 2 | public function getStatusesFilePath() |
|
133 | |||
134 | /** |
||
135 | * @inheritDoc |
||
136 | */ |
||
137 | 98 | public function reset() |
|
145 | |||
146 | /** |
||
147 | * @inheritDoc |
||
148 | */ |
||
149 | 6 | public function enable(Module $module) |
|
153 | |||
154 | /** |
||
155 | * @inheritDoc |
||
156 | */ |
||
157 | 6 | public function disable(Module $module) |
|
161 | |||
162 | /** |
||
163 | * @inheritDoc |
||
164 | */ |
||
165 | 16 | public function isStatus(Module $module, bool $status): bool |
|
172 | |||
173 | /** |
||
174 | * @inheritDoc |
||
175 | */ |
||
176 | 4 | public function setActive(Module $module, bool $active) |
|
180 | |||
181 | /** |
||
182 | * @inheritDoc |
||
183 | */ |
||
184 | 130 | public function setActiveByName(string $name, bool $status) |
|
190 | |||
191 | /** |
||
192 | * @inheritDoc |
||
193 | */ |
||
194 | 2 | public function delete(Module $module) |
|
201 | } |
||
202 |