SpecialPageFactory_deprecated.php 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * Factory for handling the special page list and generating SpecialPage objects.
  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. * @ingroup SpecialPage
  22. * @defgroup SpecialPage SpecialPage
  23. */
  24. use MediaWiki\Linker\LinkRenderer;
  25. use MediaWiki\MediaWikiServices;
  26. // phpcs:disable MediaWiki.Files.ClassMatchesFilename.NotMatch
  27. /**
  28. * Wrapper for backward compatibility for old callers that used static methods.
  29. *
  30. * @deprecated since 1.32, use the SpecialPageFactory service instead
  31. */
  32. class SpecialPageFactory {
  33. public static function getNames() : array {
  34. return MediaWikiServices::getInstance()->getSpecialPageFactory()->getNames();
  35. }
  36. public static function resolveAlias( $alias ) : array {
  37. return MediaWikiServices::getInstance()->getSpecialPageFactory()->resolveAlias( $alias );
  38. }
  39. public static function exists( $name ) {
  40. return MediaWikiServices::getInstance()->getSpecialPageFactory()->exists( $name );
  41. }
  42. public static function getPage( $name ) {
  43. return MediaWikiServices::getInstance()->getSpecialPageFactory()->getPage( $name );
  44. }
  45. public static function getUsablePages( User $user = null ) : array {
  46. global $wgUser;
  47. $user = $user ?? $wgUser;
  48. return MediaWikiServices::getInstance()->getSpecialPageFactory()->getUsablePages( $user );
  49. }
  50. public static function getRegularPages() : array {
  51. return MediaWikiServices::getInstance()->getSpecialPageFactory()->getRegularPages();
  52. }
  53. public static function getRestrictedPages( User $user = null ) : array {
  54. global $wgUser;
  55. $user = $user ?? $wgUser;
  56. return MediaWikiServices::getInstance()->getSpecialPageFactory()->getRestrictedPages( $user );
  57. }
  58. public static function executePath( Title &$title, IContextSource &$context, $including = false,
  59. LinkRenderer $linkRenderer = null
  60. ) {
  61. return MediaWikiServices::getInstance()->getSpecialPageFactory()
  62. ->executePath( $title, $context, $including, $linkRenderer );
  63. }
  64. public static function capturePath(
  65. Title $title, IContextSource $context, LinkRenderer $linkRenderer = null
  66. ) {
  67. return MediaWikiServices::getInstance()->getSpecialPageFactory()
  68. ->capturePath( $title, $context, $linkRenderer );
  69. }
  70. public static function getLocalNameFor( $name, $subpage = false ) {
  71. return MediaWikiServices::getInstance()->getSpecialPageFactory()
  72. ->getLocalNameFor( $name, $subpage );
  73. }
  74. public static function getTitleForAlias( $alias ) {
  75. return MediaWikiServices::getInstance()->getSpecialPageFactory()
  76. ->getTitleForAlias( $alias );
  77. }
  78. /**
  79. * No-op since 1.32, call overrideMwServices() instead
  80. */
  81. public static function resetList() {
  82. }
  83. }