registration: Allow to require environment abilities
[lhc/web/wiklou.git] / includes / registration / ExtensionDependencyError.php
1 <?php
2 /**
3 * Copyright (C) 2018 Kunal Mehta <legoktm@member.fsf.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 */
20
21 /**
22 * @since 1.31
23 */
24 class ExtensionDependencyError extends Exception {
25
26 /**
27 * @var string[]
28 */
29 public $missingExtensions = [];
30
31 /**
32 * @var string[]
33 */
34 public $missingSkins = [];
35
36 /**
37 * @var string[]
38 */
39 public $incompatibleExtensions = [];
40
41 /**
42 * @var string[]
43 */
44 public $incompatibleSkins = [];
45
46 /**
47 * @var bool
48 */
49 public $incompatibleCore = false;
50
51 /**
52 * @var bool
53 */
54 public $incompatiblePhp = false;
55
56 /**
57 * @var string[]
58 */
59 public $missingPhpExtensions = [];
60
61 /**
62 * @var string[]
63 */
64 public $missingAbilities = [];
65
66 /**
67 * @param array $errors Each error has a 'msg' and 'type' key at minimum
68 */
69 public function __construct( array $errors ) {
70 $msg = '';
71 foreach ( $errors as $info ) {
72 $msg .= $info['msg'] . "\n";
73 switch ( $info['type'] ) {
74 case 'incompatible-core':
75 $this->incompatibleCore = true;
76 break;
77 case 'incompatible-php':
78 $this->incompatiblePhp = true;
79 break;
80 case 'missing-phpExtension':
81 $this->missingPhpExtensions[] = $info['missing'];
82 break;
83 case 'missing-ability':
84 $this->missingAbilities[] = $info['missing'];
85 break;
86 case 'missing-skins':
87 $this->missingSkins[] = $info['missing'];
88 break;
89 case 'missing-extensions':
90 $this->missingExtensions[] = $info['missing'];
91 break;
92 case 'incompatible-skins':
93 $this->incompatibleSkins[] = $info['incompatible'];
94 break;
95 case 'incompatible-extensions':
96 $this->incompatibleExtensions[] = $info['incompatible'];
97 break;
98 // default: continue
99 }
100 }
101
102 parent::__construct( $msg );
103 }
104
105 }