ExtensionDependencyError.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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. * @param array $errors Each error has a 'msg' and 'type' key at minimum
  46. */
  47. public function __construct( array $errors ) {
  48. $msg = '';
  49. foreach ( $errors as $info ) {
  50. $msg .= $info['msg'] . "\n";
  51. switch ( $info['type'] ) {
  52. case 'incompatible-core':
  53. $this->incompatibleCore = true;
  54. break;
  55. case 'missing-skins':
  56. $this->missingSkins[] = $info['missing'];
  57. break;
  58. case 'missing-extensions':
  59. $this->missingExtensions[] = $info['missing'];
  60. break;
  61. case 'incompatible-skins':
  62. $this->incompatibleSkins[] = $info['incompatible'];
  63. break;
  64. case 'incompatible-extensions':
  65. $this->incompatibleExtensions[] = $info['incompatible'];
  66. break;
  67. // default: continue
  68. }
  69. }
  70. parent::__construct( $msg );
  71. }
  72. }