Go to the documentation of this file.
25 public static function main() {
40 $conf = $services->getMainConfig();
41 $objectFactory = $services->getObjectFactory();
43 if ( !$conf->get(
'EnableRestAPI' ) ) {
45 'Set $wgEnableRestAPI to true to enable the experimental REST API' );
50 'cookiePrefix' => $conf->get(
'CookiePrefix' )
53 $responseFactory =
new ResponseFactory( self::getTextFormatters( $services ) );
57 $services->getPermissionManager() );
60 $restValidator =
new Validator( $objectFactory,
61 $services->getPermissionManager(),
68 [
"$IP/includes/Rest/coreRoutes.json" ],
70 $conf->get(
'RestPath' ),
71 $services->getLocalServerObjectCache(),
78 $entryPoint =
new self(
93 $langs = array_unique( [
99 foreach ( $langs as
$lang ) {
100 $textFormatters[] = $factory->getTextFormatter(
$lang );
102 return $textFormatters;
116 $response = $this->router->execute( $this->request );
118 $this->webResponse->header(
119 'HTTP/' .
$response->getProtocolVersion() .
' ' .
124 $this->webResponse->header(
$line );
127 foreach (
$response->getCookies() as $cookie ) {
128 $this->webResponse->setCookie(
132 $cookie[
'options'] );
144 $stream->copyToStream( fopen(
'php://output',
'w' ) );
147 $buffer = $stream->read( 65536 );
148 if ( $buffer ===
'' ) {
156 $mw->doPostOutputShutdown(
'fast' );
if(!isset( $args[0])) $lang
__construct(RequestContext $context, RequestInterface $request, WebResponse $webResponse, Router $router)
if(! $wgRequest->checkUrlExtension()) if(isset( $_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] !='') $wgTitle
RequestInterface $request
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Group all the pieces relevant to the context of a request into one instance.
static getMain()
Get the RequestContext object associated with the main request.
Represents a title within MediaWiki.
wfHttpError( $code, $label, $desc)
Provide a simple HTTP error.
if(! $wgDBerrorLogTZ) $wgRequest
Allow programs to request this object from WebRequest::response() and handle all outputting (or lack ...
setTitle(Title $title=null)
static getTextFormatters(MediaWikiServices $services)
Get a TextFormatter array from MediaWikiServices.