|
MediaWiki master
|
MatcherBasedModules respond to requests by matching the requested path against a list of known routes to identify the appropriate handler. More...
Inherits MediaWiki\Rest\Module\Module.
Inherited by MediaWiki\Rest\Module\ExtraRoutesModule, and MediaWiki\Rest\Module\SpecBasedModule.

Public Member Functions | |||||||
| 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 (Router $router, string $pathPrefix, ResponseFactory $responseFactory, BasicAuthorizerInterface $basicAuth, ObjectFactory $objectFactory, Validator $restValidator, ErrorReporter $errorReporter, HookContainer $hookContainer) | |||||||
| execute (string $path, RequestInterface $request) | |||||||
| Find the handler for a request and execute it. | |||||||
| getDefinedPaths () | |||||||
| getHandlerForPath (string $path, RequestInterface $request, bool $initForExecute=false) | |||||||
| Create a Handler for the given path, taking into account the request method. | |||||||
| getModuleDescription () | |||||||
| Returns fields to be included when describing this module in the discovery document. | |||||||
| getOpenApiInfo () | |||||||
| Return an array with data to be included in an OpenAPI "info" object describing this module. | |||||||
| getPathPrefix () | |||||||
| getRouter () | |||||||
| setCors (CorsUtils $cors) | |||||||
| setStats (StatsFactory $stats) | |||||||
Protected Member Functions | |
| addRoute ( $method, string $path, array $info) | |
| getConfigHash () | |
| Get a config version hash for cache invalidation. | |
| getMatchers () | |
| Get an array of PathMatcher objects indexed by HTTP method. | |
| initRoutes () | |
| Initialize matchers by calling addRoute() for each known route. | |
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. | |
Additional Inherited Members | |
Static Public Member Functions inherited from MediaWiki\Rest\Module\Module | |
| static | loadJsonFile (string $fileName) |
| Loads a module specification from a file. | |
Public Attributes inherited from MediaWiki\Rest\Module\Module | |
| const | CACHE_CONFIG_HASH_KEY = 'CONFIG-HASH' |
Protected Attributes inherited from MediaWiki\Rest\Module\Module | |
| string | $pathPrefix |
| ResponseFactory | $responseFactory |
MatcherBasedModules respond to requests by matching the requested path against a list of known routes to identify the appropriate handler.
Definition at line 16 of file MatcherBasedModule.php.
|
protected |
| string | string[] | $method | The method(s) the route should be registered for |
| string | $path | The path pattern for the route |
| array | $info | Information to be associated with the route. Supported keys:
|
Definition at line 83 of file MatcherBasedModule.php.
References $path, and MediaWiki\Rest\PathTemplateMatcher\PathMatcher\add().
| 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.
| string | $path | |
| string | $requestMethod |
handler or spec field must be set.Reimplemented from MediaWiki\Rest\Module\Module.
Definition at line 107 of file MatcherBasedModule.php.
| MediaWiki\Rest\Module\MatcherBasedModule::getAllowedMethods | ( | string | $relPath | ) |
Get the allowed methods for a path.
Useful to check for 405 wrong method.
| string | $relPath | A concrete request path. |
Reimplemented from MediaWiki\Rest\Module\Module.
Definition at line 140 of file MatcherBasedModule.php.
| MediaWiki\Rest\Module\MatcherBasedModule::getCacheData | ( | ) |
Return data that can later be used to initialize a new instance of this module in a fast and efficient way.
Reimplemented from MediaWiki\Rest\Module\Module.
Definition at line 23 of file MatcherBasedModule.php.
|
abstractprotected |
Get a config version hash for cache invalidation.
Reimplemented in MediaWiki\Rest\Module\ExtraRoutesModule, and MediaWiki\Rest\Module\SpecBasedModule.
|
protected |
Get an array of PathMatcher objects indexed by HTTP method.
Definition at line 62 of file MatcherBasedModule.php.
| MediaWiki\Rest\Module\MatcherBasedModule::initFromCacheData | ( | array | $cacheData | ) |
Initialize from the given cache data if possible.
This allows fast initialization based on data that was cached during a previous invocation of the module.
Implementations are responsible for verifying that the cache data matches the information provided to the constructor, to protect against a situation where configuration was updated in a way that affects the operation of the module.
| array | $cacheData | Data generated by getCacheData(), implementations are free to choose the format. |
Reimplemented from MediaWiki\Rest\Module\Module.
Definition at line 34 of file MatcherBasedModule.php.
|
abstractprotected |
Initialize matchers by calling addRoute() for each known route.
Reimplemented in MediaWiki\Rest\Module\ExtraRoutesModule, and MediaWiki\Rest\Module\SpecBasedModule.