MediaWiki master
MediaWiki\Rest\Router Class Reference

The REST router is responsible for gathering module configuration, matching an input path against the defined modules, and constructing and executing the relevant module for a request. More...

Public Member Functions

 __construct (array $routeFiles, array $extraRoutes, ServiceOptions $options, BagOStuff $cacheBag, ResponseFactory $responseFactory, BasicAuthorizerInterface $basicAuth, Authority $authority, ObjectFactory $objectFactory, Validator $restValidator, ErrorReporter $errorReporter, HookContainer $hookContainer, Session $session)
 
 execute (RequestInterface $request)
 
 getModule (string $name)
 
 getModuleForPath (string $fullPath)
 
 getModuleIds ()
 
 getPrivateRouteUrl (string $routeWithModulePrefix, array $pathParams=[], array $queryParams=[])
 
 getRestbaseCompatErrorData (RequestInterface $request, LocalizedHttpException $e)
 
 getRoutePath (string $routeWithModulePrefix, array $pathParams=[], array $queryParams=[])
 
 getRouteUrl (string $routeWithModulePrefix, array $pathParams=[], array $queryParams=[])
 
 isRestbaseCompatEnabled (RequestInterface $request)
 
 prepareHandler (Handler $handler)
 Prepare the handler by injecting relevant service objects and state into $handler.
 
 setCors (CorsUtils $cors)
 
 setStats (StatsFactory $stats)
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 

Protected Member Functions

 substPathParams (string $route, array $pathParams)
 

Detailed Description

The REST router is responsible for gathering module configuration, matching an input path against the defined modules, and constructing and executing the relevant module for a request.

Definition at line 30 of file Router.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Rest\Router::__construct ( array $routeFiles,
array $extraRoutes,
ServiceOptions $options,
BagOStuff $cacheBag,
ResponseFactory $responseFactory,
BasicAuthorizerInterface $basicAuth,
Authority $authority,
ObjectFactory $objectFactory,
Validator $restValidator,
ErrorReporter $errorReporter,
HookContainer $hookContainer,
Session $session )
Parameters
string[]$routeFiles
array[]$extraRoutes
ServiceOptions$options
BagOStuff$cacheBagA cache in which to store the matcher trees
ResponseFactory$responseFactory
BasicAuthorizerInterface$basicAuth
Authority$authority
ObjectFactory$objectFactory
Validator$restValidator
ErrorReporter$errorReporter
HookContainer$hookContainer
Session$session
Access: internal

Definition at line 104 of file Router.php.

References MediaWiki\Config\ServiceOptions\assertRequiredOptions(), MediaWiki\MainConfigNames\CanonicalServer, MediaWiki\Config\ServiceOptions\get(), MediaWiki\MainConfigNames\InternalServer, MediaWiki\MainConfigNames\RestPath, and MediaWiki\MainConfigNames\ScriptPath.

Member Function Documentation

◆ execute()

MediaWiki\Rest\Router::execute ( RequestInterface $request)

Definition at line 443 of file Router.php.

◆ getModule()

MediaWiki\Rest\Router::getModule ( string $name)

Definition at line 360 of file Router.php.

◆ getModuleForPath()

MediaWiki\Rest\Router::getModuleForPath ( string $fullPath)

Definition at line 355 of file Router.php.

◆ getModuleIds()

MediaWiki\Rest\Router::getModuleIds ( )
Returns
string[]

Definition at line 351 of file Router.php.

◆ getPrivateRouteUrl()

MediaWiki\Rest\Router::getPrivateRouteUrl ( string $routeWithModulePrefix,
array $pathParams = [],
array $queryParams = [] )

Definition at line 419 of file Router.php.

◆ getRestbaseCompatErrorData()

MediaWiki\Rest\Router::getRestbaseCompatErrorData ( RequestInterface $request,
LocalizedHttpException $e )
Access: internal
Returns
array

Definition at line 583 of file Router.php.

◆ getRoutePath()

MediaWiki\Rest\Router::getRoutePath ( string $routeWithModulePrefix,
array $pathParams = [],
array $queryParams = [] )
Since
1.42

Definition at line 401 of file Router.php.

◆ getRouteUrl()

MediaWiki\Rest\Router::getRouteUrl ( string $routeWithModulePrefix,
array $pathParams = [],
array $queryParams = [] )

Definition at line 411 of file Router.php.

◆ isRestbaseCompatEnabled()

MediaWiki\Rest\Router::isRestbaseCompatEnabled ( RequestInterface $request)
Access: internal
Returns
bool

Definition at line 568 of file Router.php.

◆ prepareHandler()

MediaWiki\Rest\Router::prepareHandler ( Handler $handler)

Prepare the handler by injecting relevant service objects and state into $handler.

Access: internal

Definition at line 496 of file Router.php.

References MediaWiki\Rest\Handler\initServices(), and MediaWiki\Rest\Handler\initSession().

◆ setCors()

MediaWiki\Rest\Router::setCors ( CorsUtils $cors)
Parameters
CorsUtils$cors
Returns
self

Definition at line 512 of file Router.php.

◆ setStats()

MediaWiki\Rest\Router::setStats ( StatsFactory $stats)
Access: internal
Parameters
StatsFactory$stats
Returns
self

Definition at line 525 of file Router.php.

◆ substPathParams()

MediaWiki\Rest\Router::substPathParams ( string $route,
array $pathParams )
protected
Parameters
string$route
array$pathParams
Returns
string

Definition at line 433 of file Router.php.

Member Data Documentation

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\Rest\Router::CONSTRUCTOR_OPTIONS
Initial value:
= [
]
const CanonicalServer
Name constant for the CanonicalServer setting, for use with Config::get()
const ScriptPath
Name constant for the ScriptPath setting, for use with Config::get()
const RestPath
Name constant for the RestPath setting, for use with Config::get()
const InternalServer
Name constant for the InternalServer setting, for use with Config::get()
Access: internal

Definition at line 82 of file Router.php.


The documentation for this class was generated from the following file: