MediaWiki  1.30.0
SpecialPageData.php
Go to the documentation of this file.
1 <?php
2 
11 
15  private $requestHandler = null;
16 
17  public function __construct() {
18  parent::__construct( 'PageData' );
19  }
20 
32  $this->requestHandler = $requestHandler;
33  }
34 
39  protected function initDependencies() {
40  if ( $this->requestHandler === null ) {
41  $this->requestHandler = $this->newDefaultRequestHandler();
42  }
43  }
44 
50  private function newDefaultRequestHandler() {
51  return new PageDataRequestHandler();
52  }
53 
61  public function execute( $subPage ) {
62  $this->initDependencies();
63 
64  // If there is no title, show an HTML form
65  // TODO: Don't do this if HTML is not acceptable according to HTTP headers.
66  if ( !$this->requestHandler->canHandleRequest( $subPage, $this->getRequest() ) ) {
67  $this->showForm();
68  return;
69  }
70 
71  $this->requestHandler->handleRequest( $subPage, $this->getRequest(), $this->getOutput() );
72  }
73 
77  public function showForm() {
78  $this->getOutput()->showErrorPage( 'pagedata-title', 'pagedata-text' );
79  }
80 
81  public function isListed() {
82  // Do not list this page in Special:SpecialPages
83  return false;
84  }
85 
86 }
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:675
PageDataRequestHandler
Request handler implementing a data interface for mediawiki pages.
Definition: PageDataRequestHandler.php:14
SpecialPageData\newDefaultRequestHandler
newDefaultRequestHandler()
Creates a PageDataRequestHandler based on global defaults.
Definition: SpecialPageData.php:50
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:31
SpecialPageData\__construct
__construct()
Definition: SpecialPageData.php:17
SpecialPageData
Special page to act as an endpoint for accessing raw page data.
Definition: SpecialPageData.php:10
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:665
SpecialPageData\showForm
showForm()
Shows an informative page to the user; Called when there is no page to output.
Definition: SpecialPageData.php:77
SpecialPageData\isListed
isListed()
Whether this special page is listed in Special:SpecialPages.
Definition: SpecialPageData.php:81
SpecialPageData\$requestHandler
PageDataRequestHandler null $requestHandler
Definition: SpecialPageData.php:15
SpecialPageData\execute
execute( $subPage)
Definition: SpecialPageData.php:61
SpecialPageData\initDependencies
initDependencies()
Initialize any un-initialized members from global context.
Definition: SpecialPageData.php:39