ExtensionDependencyError.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. * @since 1.31
  22. */
  23. class ExtensionDependencyError extends Exception {
  24. /**
  25. * @var string[]
  26. */
  27. public $missingExtensions = [];
  28. /**
  29. * @var string[]
  30. */
  31. public $missingSkins = [];
  32. /**
  33. * @var string[]
  34. */
  35. public $incompatibleExtensions = [];
  36. /**
  37. * @var string[]
  38. */
  39. public $incompatibleSkins = [];
  40. /**
  41. * @var bool
  42. */
  43. public $incompatibleCore = false;
  44. /**
  45. * @var bool
  46. */
  47. public $incompatiblePhp = false;
  48. /**
  49. * @var string[]
  50. */
  51. public $missingPhpExtensions = [];
  52. /**
  53. * @var string[]
  54. */
  55. public $missingAbilities = [];
  56. /**
  57. * @param array $errors Each error has a 'msg' and 'type' key at minimum
  58. */
  59. public function __construct( array $errors ) {
  60. $msg = '';
  61. foreach ( $errors as $info ) {
  62. $msg .= $info['msg'] . "\n";
  63. switch ( $info['type'] ) {
  64. case 'incompatible-core':
  65. $this->incompatibleCore = true;
  66. break;
  67. case 'incompatible-php':
  68. $this->incompatiblePhp = true;
  69. break;
  70. case 'missing-phpExtension':
  71. $this->missingPhpExtensions[] = $info['missing'];
  72. break;
  73. case 'missing-ability':
  74. $this->missingAbilities[] = $info['missing'];
  75. break;
  76. case 'missing-skins':
  77. $this->missingSkins[] = $info['missing'];
  78. break;
  79. case 'missing-extensions':
  80. $this->missingExtensions[] = $info['missing'];
  81. break;
  82. case 'incompatible-skins':
  83. $this->incompatibleSkins[] = $info['incompatible'];
  84. break;
  85. case 'incompatible-extensions':
  86. $this->incompatibleExtensions[] = $info['incompatible'];
  87. break;
  88. // default: continue
  89. }
  90. }
  91. parent::__construct( $msg );
  92. }
  93. }