39 $responseFactory =
new ResponseFactory( self::getTextFormatters( $services ) );
42 $services->getPermissionManager() );
44 $objectFactory = $services->getObjectFactory();
45 $restValidator =
new Validator( $objectFactory,
46 $services->getPermissionManager(),
48 RequestContext::getMain()->getUser()
52 $routeFiles = array_merge(
53 [
'includes/Rest/coreRoutes.json' ],
54 $conf->get(
'RestAPIAdditionalRouteFiles' )
56 array_walk( $routeFiles,
function ( &$val, $key ) {
63 ExtensionRegistry::getInstance()->getAttribute(
'RestRoutes' ),
64 $conf->get(
'CanonicalServer' ),
65 $conf->get(
'RestPath' ),
66 $services->getLocalServerObjectCache(),
71 $services->getHookContainer()
79 if ( self::$mainRequest === null ) {
82 'cookiePrefix' => $conf->get(
'CookiePrefix' )
85 return self::$mainRequest;
88 public static function main() {
92 $context = RequestContext::getMain();
99 $services = MediaWikiServices::getInstance();
100 $conf = $services->getMainConfig();
102 $request = self::getMainRequest();
104 $router = self::createRouter( $context, $request );
106 $entryPoint =
new self(
111 $entryPoint->execute();
121 $langs = array_unique( [
125 $textFormatters = [];
127 foreach ( $langs as
$lang ) {
128 $textFormatters[] = $factory->getTextFormatter(
$lang );
130 return $textFormatters;
136 $this->context = $context;
137 $this->request = $request;
138 $this->webResponse = $webResponse;
139 $this->router = $router;
144 $response = $this->router->execute( $this->request );
146 $this->webResponse->header(
147 'HTTP/' . $response->getProtocolVersion() .
' ' .
148 $response->getStatusCode() .
' ' .
149 $response->getReasonPhrase() );
151 foreach ( $response->getRawHeaderLines() as
$line ) {
152 $this->webResponse->header(
$line );
155 foreach ( $response->getCookies() as $cookie ) {
156 $this->webResponse->setCookie(
160 $cookie[
'options'] );
166 $stream = $response->getBody();
169 MediaWiki::preOutputCommit( $this->context );
172 $stream->copyToStream( fopen(
'php://output',
'w' ) );
175 $buffer = $stream->read( 65536 );
176 if ( $buffer ===
'' ) {
184 $mw->doPostOutputShutdown();
if(! $wgDBerrorLogTZ) $wgRequest
if(ini_get('mbstring.func_overload')) if(!defined('MW_ENTRY_POINT'))
Pre-config setup: Before loading LocalSettings.php.
static createRouter(IContextSource $context, RequestInterface $request)
static RequestInterface $mainRequest
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 @newable.
Represents a title within MediaWiki.
Allow programs to request this object from WebRequest::response() and handle all outputting (or lack ...
Interface for objects which can provide a MediaWiki context on request.
if(!isset( $args[0])) $lang