1 | <?php |
||
2 | |||
3 | namespace OSInet\qa; |
||
4 | |||
5 | |||
6 | class ForceRemoved { |
||
7 | |||
8 | public static function create() { |
||
9 | return new static(); |
||
10 | } |
||
11 | |||
12 | protected function getExtensions() { |
||
13 | $result = db_select('system', 's' )->fields('s', [ |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
14 | 'filename', |
||
15 | 'name', |
||
16 | 'type', |
||
17 | 'status', |
||
18 | 'bootstrap', |
||
19 | 'schema_version', |
||
20 | 'weight', |
||
21 | 'info', |
||
22 | ])->execute(); |
||
23 | |||
24 | $extensions = iterator_to_array($result); |
||
25 | return $extensions; |
||
26 | } |
||
27 | |||
28 | protected function filterMissing($extension) { |
||
29 | $path = $extension->filename; |
||
30 | return !file_exists($path); |
||
31 | } |
||
32 | |||
33 | protected function stripInfo(\stdClass $extension) { |
||
34 | switch ($extension->schema_version) { |
||
35 | case 0: |
||
36 | $state = 'disabled'; |
||
37 | break; |
||
38 | case -1: |
||
39 | $state = 'uninstalled'; |
||
40 | break; |
||
41 | default: |
||
42 | $state = "enabled:{$extension->schema_version}"; |
||
43 | break; |
||
44 | } |
||
45 | $info = unserialize($extension->info); |
||
46 | |||
47 | $item = [ |
||
48 | 'name' => $extension->name, |
||
49 | 'type' => $extension->type, |
||
50 | 'state' => $state, |
||
51 | 'dependencies' => isset($info['dependencies']) ? $info['dependencies'] : [], |
||
52 | ]; |
||
53 | |||
54 | return $item; |
||
55 | } |
||
56 | |||
57 | public function find() { |
||
58 | $missing = array_filter($this->getExtensions(), [$this, 'filterMissing']); |
||
59 | $items = array_map([$this, 'stripInfo'], $missing); |
||
60 | return json_encode($items, JSON_PRETTY_PRINT); |
||
61 | } |
||
62 | } |
||
63 |