InstallerOverrides.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /**
  3. * MediaWiki installer overrides. See mw-config/overrides/README for details.
  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. * http://www.gnu.org/copyleft/gpl.html
  19. *
  20. * @file
  21. */
  22. /**
  23. * @since 1.20
  24. */
  25. class InstallerOverrides {
  26. private static function getOverrides() {
  27. global $IP;
  28. static $overrides;
  29. if ( !$overrides ) {
  30. $overrides = [
  31. 'LocalSettingsGenerator' => LocalSettingsGenerator::class,
  32. 'WebInstaller' => WebInstaller::class,
  33. 'CliInstaller' => CliInstaller::class,
  34. ];
  35. foreach ( glob( "$IP/mw-config/overrides/*.php" ) as $file ) {
  36. require $file;
  37. }
  38. }
  39. return $overrides;
  40. }
  41. /**
  42. * Instantiates and returns an instance of LocalSettingsGenerator or its descendant classes
  43. * @param Installer $installer
  44. * @return LocalSettingsGenerator
  45. */
  46. public static function getLocalSettingsGenerator( Installer $installer ) {
  47. $className = self::getOverrides()['LocalSettingsGenerator'];
  48. return new $className( $installer );
  49. }
  50. /**
  51. * Instantiates and returns an instance of WebInstaller or its descendant classes
  52. * @param WebRequest $request
  53. * @return WebInstaller
  54. */
  55. public static function getWebInstaller( WebRequest $request ) {
  56. $className = self::getOverrides()['WebInstaller'];
  57. return new $className( $request );
  58. }
  59. /**
  60. * Instantiates and returns an instance of CliInstaller or its descendant classes
  61. * @param string $siteName
  62. * @param string|null $admin
  63. * @param array $options
  64. * @return CliInstaller
  65. */
  66. public static function getCliInstaller( $siteName, $admin = null, array $options = [] ) {
  67. $className = self::getOverrides()['CliInstaller'];
  68. return new $className( $siteName, $admin, $options );
  69. }
  70. }