MediaWiki REL1_35
|
The REST router is responsible for gathering handler configuration, matching an input path and HTTP method against the defined routes, and constructing and executing the relevant handler for a request. More...
Public Member Functions | |
__construct ( $routeFiles, $extraRoutes, $baseUrl, $rootPath, BagOStuff $cacheBag, ResponseFactory $responseFactory, BasicAuthorizerInterface $basicAuth, ObjectFactory $objectFactory, Validator $restValidator, HookContainer $hookContainer=null) | |
execute (RequestInterface $request) | |
Find the handler for a request and execute it. | |
getRouteUrl ( $route, $pathParams=[], $queryParams=[]) | |
Returns a full URL for the given route. | |
Private Member Functions | |
createHandler (RequestInterface $request, array $spec) | |
Create a handler from its spec. | |
executeHandler ( $handler) | |
Execute a fully-constructed handler. | |
fetchCacheData () | |
Get the cache data, or false if it is missing or invalid. | |
getAllRoutes () | |
Get an iterator for all defined routes, including loading the routes from the JSON files. | |
getCacheKey () | |
getConfigHash () | |
Get a config version hash for cache invalidation. | |
getMatchers () | |
Get an array of PathMatcher objects indexed by HTTP method. | |
getRelativePath ( $path) | |
Remove the path prefix $this->rootPath. | |
getRouteFileTimestamps () | |
Get an array of last modification times of the defined route files. | |
getRoutesFromFiles () | |
Load the defined JSON files and return the merged routes. | |
Private Attributes | |
string | $baseUrl |
BasicAuthorizerInterface | $basicAuth |
BagOStuff | $cacheBag |
string null | $configHash |
array | $extraRoutes |
HookContainer | $hookContainer |
PathMatcher[] null | $matchers |
Path matchers by method. | |
ObjectFactory | $objectFactory |
ResponseFactory | $responseFactory |
Validator | $restValidator |
string | $rootPath |
string[] | $routeFiles |
int[] null | $routeFileTimestamps |
array null | $routesFromFiles |
The REST router is responsible for gathering handler configuration, matching an input path and HTTP method against the defined routes, and constructing and executing the relevant handler for a request.
Definition at line 20 of file Router.php.
MediaWiki\Rest\Router::__construct | ( | $routeFiles, | |
$extraRoutes, | |||
$baseUrl, | |||
$rootPath, | |||
BagOStuff | $cacheBag, | ||
ResponseFactory | $responseFactory, | ||
BasicAuthorizerInterface | $basicAuth, | ||
ObjectFactory | $objectFactory, | ||
Validator | $restValidator, | ||
HookContainer | $hookContainer = null |
||
) |
Definition at line 76 of file Router.php.
References MediaWiki\Rest\Router\$baseUrl, MediaWiki\Rest\Router\$basicAuth, MediaWiki\Rest\Router\$cacheBag, MediaWiki\Rest\Router\$extraRoutes, MediaWiki\Rest\Router\$hookContainer, MediaWiki\Rest\Router\$objectFactory, MediaWiki\Rest\Router\$responseFactory, MediaWiki\Rest\Router\$restValidator, MediaWiki\Rest\Router\$rootPath, MediaWiki\Rest\Router\$routeFiles, and MediaWiki\MediaWikiServices\getInstance().
|
private |
Create a handler from its spec.
RequestInterface | $request | |
array | $spec |
Definition at line 332 of file Router.php.
Referenced by MediaWiki\Rest\Router\execute().
MediaWiki\Rest\Router::execute | ( | RequestInterface | $request | ) |
Find the handler for a request and execute it.
RequestInterface | $request |
Definition at line 265 of file Router.php.
References MediaWiki\Rest\Router\$matchers, $path, MediaWiki\Rest\Router\createHandler(), MediaWiki\Rest\Router\executeHandler(), MediaWiki\Rest\Router\getMatchers(), MediaWiki\Rest\RequestInterface\getMethod(), MediaWiki\Rest\Router\getRelativePath(), MediaWiki\Rest\RequestInterface\getUri(), MediaWiki\Rest\PathTemplateMatcher\PathMatcher\match(), and MediaWiki\Rest\RequestInterface\setPathParams().
|
private |
Execute a fully-constructed handler.
Handler | $handler |
Definition at line 348 of file Router.php.
Referenced by MediaWiki\Rest\Router\execute().
|
private |
Get the cache data, or false if it is missing or invalid.
Definition at line 103 of file Router.php.
References MediaWiki\Rest\Router\getCacheKey(), and MediaWiki\Rest\Router\getConfigHash().
Referenced by MediaWiki\Rest\Router\getMatchers().
|
private |
Get an iterator for all defined routes, including loading the routes from the JSON files.
Definition at line 177 of file Router.php.
References MediaWiki\Rest\Router\getRoutesFromFiles().
Referenced by MediaWiki\Rest\Router\getMatchers().
|
private |
Definition at line 116 of file Router.php.
Referenced by MediaWiki\Rest\Router\fetchCacheData(), and MediaWiki\Rest\Router\getMatchers().
|
private |
Get a config version hash for cache invalidation.
Definition at line 125 of file Router.php.
References MediaWiki\Rest\Router\$configHash, and MediaWiki\Rest\Router\getRouteFileTimestamps().
Referenced by MediaWiki\Rest\Router\fetchCacheData(), and MediaWiki\Rest\Router\getMatchers().
|
private |
Get an array of PathMatcher objects indexed by HTTP method.
Definition at line 189 of file Router.php.
References MediaWiki\Rest\Router\$matchers, MediaWiki\Rest\PathTemplateMatcher\PathMatcher\add(), MediaWiki\Rest\Router\fetchCacheData(), MediaWiki\Rest\Router\getAllRoutes(), MediaWiki\Rest\Router\getCacheKey(), MediaWiki\Rest\Router\getConfigHash(), and MediaWiki\Rest\PathTemplateMatcher\PathMatcher\newFromCache().
Referenced by MediaWiki\Rest\Router\execute().
|
private |
Remove the path prefix $this->rootPath.
Return the part of the path with the prefix removed, or false if the prefix did not match.
string | $path |
Definition at line 229 of file Router.php.
References $path.
Referenced by MediaWiki\Rest\Router\execute().
|
private |
Get an array of last modification times of the defined route files.
Definition at line 161 of file Router.php.
References MediaWiki\Rest\Router\$routeFileTimestamps.
Referenced by MediaWiki\Rest\Router\getConfigHash().
|
private |
Load the defined JSON files and return the merged routes.
Definition at line 140 of file Router.php.
References MediaWiki\Rest\Router\$routesFromFiles.
Referenced by MediaWiki\Rest\Router\getAllRoutes().
MediaWiki\Rest\Router::getRouteUrl | ( | $route, | |
$pathParams = [] , |
|||
$queryParams = [] |
|||
) |
Returns a full URL for the given route.
Intended for use in redirects.
string | $route | |
array | $pathParams | |
array | $queryParams |
Definition at line 248 of file Router.php.
References wfAppendQuery().
|
private |
Definition at line 34 of file Router.php.
Referenced by MediaWiki\Rest\Router\__construct().
|
private |
Definition at line 52 of file Router.php.
Referenced by MediaWiki\Rest\Router\__construct().
|
private |
Definition at line 40 of file Router.php.
Referenced by MediaWiki\Rest\Router\__construct().
|
private |
Definition at line 46 of file Router.php.
Referenced by MediaWiki\Rest\Router\getConfigHash().
|
private |
Definition at line 25 of file Router.php.
Referenced by MediaWiki\Rest\Router\__construct().
|
private |
Definition at line 61 of file Router.php.
Referenced by MediaWiki\Rest\Router\__construct().
|
private |
Path matchers by method.
Definition at line 43 of file Router.php.
Referenced by MediaWiki\Rest\Router\execute(), and MediaWiki\Rest\Router\getMatchers().
|
private |
Definition at line 55 of file Router.php.
Referenced by MediaWiki\Rest\Router\__construct().
|
private |
Definition at line 49 of file Router.php.
Referenced by MediaWiki\Rest\Router\__construct().
|
private |
Definition at line 58 of file Router.php.
Referenced by MediaWiki\Rest\Router\__construct().
|
private |
Definition at line 37 of file Router.php.
Referenced by MediaWiki\Rest\Router\__construct().
|
private |
Definition at line 22 of file Router.php.
Referenced by MediaWiki\Rest\Router\__construct().
|
private |
Definition at line 31 of file Router.php.
Referenced by MediaWiki\Rest\Router\getRouteFileTimestamps().
|
private |
Definition at line 28 of file Router.php.
Referenced by MediaWiki\Rest\Router\getRoutesFromFiles().