MediaWiki  1.32.5
SpecialPageData.php
Go to the documentation of this file.
1 <?php
32 
36  private $requestHandler = null;
37 
38  public function __construct() {
39  parent::__construct( 'PageData' );
40  }
41 
53  $this->requestHandler = $requestHandler;
54  }
55 
60  protected function initDependencies() {
61  if ( $this->requestHandler === null ) {
62  $this->requestHandler = $this->newDefaultRequestHandler();
63  }
64  }
65 
71  private function newDefaultRequestHandler() {
72  return new PageDataRequestHandler();
73  }
74 
82  public function execute( $subPage ) {
83  $this->initDependencies();
84 
85  // If there is no title, show an HTML form
86  // TODO: Don't do this if HTML is not acceptable according to HTTP headers.
87  if ( !$this->requestHandler->canHandleRequest( $subPage, $this->getRequest() ) ) {
88  $this->showForm();
89  return;
90  }
91 
92  $this->requestHandler->handleRequest( $subPage, $this->getRequest(), $this->getOutput() );
93  }
94 
98  public function showForm() {
99  $this->getOutput()->showErrorPage( 'pagedata-title', 'pagedata-text' );
100  }
101 
102  public function isListed() {
103  // Do not list this page in Special:SpecialPages
104  return false;
105  }
106 
107 }
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:725
PageDataRequestHandler
Request handler implementing a data interface for mediawiki pages.
Definition: PageDataRequestHandler.php:30
SpecialPageData\newDefaultRequestHandler
newDefaultRequestHandler()
Creates a PageDataRequestHandler based on global defaults.
Definition: SpecialPageData.php:71
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:35
SpecialPageData\setRequestHandler
setRequestHandler(PageDataRequestHandler $requestHandler)
Sets the request handler to be used by the special page.
Definition: SpecialPageData.php:52
SpecialPageData\__construct
__construct()
Definition: SpecialPageData.php:38
SpecialPageData
Definition: SpecialPageData.php:31
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:36
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:715
SpecialPageData\showForm
showForm()
Shows an informative page to the user; Called when there is no page to output.
Definition: SpecialPageData.php:98
SpecialPageData\isListed
isListed()
Whether this special page is listed in Special:SpecialPages.
Definition: SpecialPageData.php:102
SpecialPageData\$requestHandler
PageDataRequestHandler null $requestHandler
Definition: SpecialPageData.php:36
SpecialPageData\execute
execute( $subPage)
Definition: SpecialPageData.php:82
SpecialPageData\initDependencies
initDependencies()
Initialize any un-initialized members from global context.
Definition: SpecialPageData.php:60