25 public static function main() {
32 $context = RequestContext::getMain();
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(),
63 RequestContext::getMain()->getUser()
68 [
"$IP/includes/Rest/coreRoutes.json" ],
69 ExtensionRegistry::getInstance()->getAttribute(
'RestRoutes' ),
70 $conf->get(
'RestPath' ),
71 $services->getLocalServerObjectCache(),
78 $entryPoint =
new self(
83 $entryPoint->execute();
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'] );
141 MediaWiki::preOutputCommit( $this->context );
144 $stream->copyToStream( fopen(
'php://output',
'w' ) );
147 $buffer = $stream->read( 65536 );
148 if ( $buffer ===
'' ) {
156 $mw->doPostOutputShutdown(
'fast' );
wfHttpError( $code, $label, $desc)
Provide a simple HTTP error.
if(! $wgDBerrorLogTZ) $wgRequest
if(! $wgRequest->checkUrlExtension()) if(isset( $_SERVER['PATH_INFO']) && $_SERVER['PATH_INFO'] !='') $wgTitle
RequestInterface $request
__construct(RequestContext $context, RequestInterface $request, WebResponse $webResponse, Router $router)
static getTextFormatters(MediaWikiServices $services)
Get a TextFormatter array from MediaWikiServices.
Group all the pieces relevant to the context of a request into one instance.
setTitle(Title $title=null)
Represents a title within MediaWiki.
Allow programs to request this object from WebRequest::response() and handle all outputting (or lack ...
if(!isset( $args[0])) $lang