|
MediaWiki master
|
A Module that is based on flat route definitions in the form originally introduced in MW 1.35. More...
Inherits MediaWiki\Rest\Module\MatcherBasedModule.

Public Member Functions | |||||||
| __construct (private array $routeFiles, private readonly array $extraRoutes, Router $router, JsonLocalizer $jsonLocalizer, BasicAuthorizerInterface $basicAuth, ObjectFactory $objectFactory, Validator $restValidator, ErrorReporter $errorReporter, HookContainer $hookContainer, private readonly ServiceOptions $options,) | |||||||
| getDefinedPaths () | |||||||
| getDeprecatedDate () | |||||||
Return the timestamp at which this was or will be deprecated, or null if none.
| |||||||
| getOpenApiContact () | |||||||
| getOpenApiExternalDocs () | |||||||
Return an array with data to be included as the root-level OpenAPI "externalDocs" object describing this module's external documentation.
| |||||||
| getOpenApiInfo () | |||||||
Return an array with data to be included in an OpenAPI "info" object describing this module.
| |||||||
Public Member Functions inherited from MediaWiki\Rest\Module\MatcherBasedModule | |||||||
| findHandlerMatch (string $path, string $requestMethod) | |||||||
Determines which handler to use for the given path and returns an array describing the handler and initialization context.
| |||||||
| getAllowedMethods (string $relPath) | |||||||
| Get the allowed methods for a path. | |||||||
| getCacheData () | |||||||
| Return data that can later be used to initialize a new instance of this module in a fast and efficient way. | |||||||
| initFromCacheData (array $cacheData) | |||||||
| Initialize from the given cache data if possible. | |||||||
Public Member Functions inherited from MediaWiki\Rest\Module\Module | |||||||
| __construct (private readonly Router $router, protected readonly string $pathPrefix, protected readonly JsonLocalizer $jsonLocalizer, private readonly BasicAuthorizerInterface $basicAuth, private readonly ObjectFactory $objectFactory, private readonly Validator $restValidator, private readonly ErrorReporter $errorReporter, HookContainer $hookContainer,) | |||||||
| execute (string $path, RequestInterface $request) | |||||||
| Find the handler for a request and execute it. | |||||||
| getHandlerForPath (string $path, RequestInterface $request, bool $initForExecute=false) | |||||||
| Create a Handler for the given path, taking into account the request method. | |||||||
| getJsonLocalizer () | |||||||
| getModuleDescription () | |||||||
| Returns fields to be included when describing this module in the discovery document. | |||||||
| getOpenApiTags () | |||||||
| Return an array with data to be included in an OpenAPI "tags" object describing this module's tags. | |||||||
| getPathPrefix () | |||||||
| getRouter () | |||||||
| initForExecute (ResponseFactory $responseFactory) | |||||||
| Initialize this module for handling requests via execute(). | |||||||
| setCors (CorsUtils $cors) | |||||||
| setStats (StatsFactory $stats) | |||||||
Public Attributes | |
| const | CONSTRUCTOR_OPTIONS |
Public Attributes inherited from MediaWiki\Rest\Module\Module | |
| const | CACHE_CONFIG_HASH_KEY = 'CONFIG-HASH' |
Protected Member Functions | |
| getConfigHash () | |
| Get a config version hash for cache invalidation. | |
| initRoutes () | |
| Initialize matchers by calling addRoute() for each known route. | |
Protected Member Functions inherited from MediaWiki\Rest\Module\MatcherBasedModule | |
| addRoute ( $method, string $path, array $info) | |
| getMatchers () | |
| Get an array of PathMatcher objects indexed by HTTP method. | |
Protected Member Functions inherited from MediaWiki\Rest\Module\Module | |
| executeHandler (Handler $handler) | |
| Execute a fully-constructed handler. | |
| instantiateHandlerObject (array $spec) | |
| Creates a handler from the given spec, but does not initialize it. | |
| throwNoMatch (string $path, string $method, array $allowed) | |
| Implementations of getHandlerForPath() should call this method when they cannot handle the requested path. | |
A Module that is based on flat route definitions in the form originally introduced in MW 1.35.
This module acts as a "catch all" since it doesn't use a module prefix. So it handles all routes that do not explicitly belong to a module.
This module responds to requests by matching the requested path against a list of known routes to identify the appropriate handler. The routes are loaded from the route definition files or in extension.json files using the RestRoutes key.
Flat files just contain a list (a JSON array) or route definitions (see below). Annotated route definition files contain a map (a JSON object) with the following fields:
Each route definition maps a path pattern to a handler class. It is given as a map (JSON object) with the following fields:
The following fields are supported as a shorthand notation:
More shorthands may be added in the future.
Route definitions can contain additional fields to configure the handler. The handler can access the route definition by calling getConfig().
Definition at line 65 of file ExtraRoutesModule.php.
| MediaWiki\Rest\Module\ExtraRoutesModule::__construct | ( | private array | $routeFiles, |
| private readonly array | $extraRoutes, | ||
| Router | $router, | ||
| JsonLocalizer | $jsonLocalizer, | ||
| BasicAuthorizerInterface | $basicAuth, | ||
| ObjectFactory | $objectFactory, | ||
| Validator | $restValidator, | ||
| ErrorReporter | $errorReporter, | ||
| HookContainer | $hookContainer, | ||
| private readonly ServiceOptions | $options ) |
| string[] | $routeFiles | List of names of JSON files containing routes See the documentation of this class for a description of the file format. |
| array<int,array> | $extraRoutes Extension route array. The content of this array must be a list of route definitions. See the documentation of this class for a description of the expected structure. |
Definition at line 93 of file ExtraRoutesModule.php.
|
protected |
Get a config version hash for cache invalidation.
Reimplemented from MediaWiki\Rest\Module\MatcherBasedModule.
Definition at line 121 of file ExtraRoutesModule.php.
| MediaWiki\Rest\Module\ExtraRoutesModule::getDefinedPaths | ( | ) |
Reimplemented from MediaWiki\Rest\Module\Module.
Definition at line 176 of file ExtraRoutesModule.php.
| MediaWiki\Rest\Module\ExtraRoutesModule::getDeprecatedDate | ( | ) |
Return the timestamp at which this was or will be deprecated, or null if none.
Reimplemented from MediaWiki\Rest\Module\Module.
Definition at line 298 of file ExtraRoutesModule.php.
| MediaWiki\Rest\Module\ExtraRoutesModule::getOpenApiContact | ( | ) |
Definition at line 272 of file ExtraRoutesModule.php.
| MediaWiki\Rest\Module\ExtraRoutesModule::getOpenApiExternalDocs | ( | ) |
Return an array with data to be included as the root-level OpenAPI "externalDocs" object describing this module's external documentation.
Reimplemented from MediaWiki\Rest\Module\Module.
Definition at line 290 of file ExtraRoutesModule.php.
| MediaWiki\Rest\Module\ExtraRoutesModule::getOpenApiInfo | ( | ) |
Return an array with data to be included in an OpenAPI "info" object describing this module.
Reimplemented from MediaWiki\Rest\Module\Module.
Definition at line 252 of file ExtraRoutesModule.php.
|
protected |
Initialize matchers by calling addRoute() for each known route.
Reimplemented from MediaWiki\Rest\Module\MatcherBasedModule.
Definition at line 199 of file ExtraRoutesModule.php.
References $path.
| const MediaWiki\Rest\Module\ExtraRoutesModule::CONSTRUCTOR_OPTIONS |
Definition at line 67 of file ExtraRoutesModule.php.