MediaWiki REL1_34
|
Public Member Functions | |
execute () | |
Execute the handler. | |
getBodyValidator ( $contentType) | |
Fetch the BodyValidator. | |
getConfig () | |
Get the configuration array for the current route. | |
getParamSettings () | |
Fetch ParamValidator settings for parameters. | |
getRequest () | |
Get the current request. | |
getResponseFactory () | |
Get the ResponseFactory which can be used to generate Response objects. | |
getValidatedBody () | |
Fetch the validated body. | |
getValidatedParams () | |
Fetch the validated parameters. | |
init (Router $router, RequestInterface $request, array $config, ResponseFactory $responseFactory) | |
Initialise with dependencies from the Router. | |
needsReadAccess () | |
Indicates whether this route requires read rights. | |
needsWriteAccess () | |
Indicates whether this route requires write access. | |
validate (Validator $restValidator) | |
Validate the request parameters/attributes and body. | |
Public Attributes | |
const | PARAM_SOURCE = 'rest-param-source' |
(string) ParamValidator constant to specify the source of the parameter. | |
Protected Member Functions | |
getETag () | |
The subclass should override this to provide an ETag for the current request. | |
getLastModified () | |
The subclass should override this to provide the maximum last modified timestamp for the current request. | |
getRouter () | |
Get the Router. | |
Private Attributes | |
array | $config |
RequestInterface | $request |
ResponseFactory | $responseFactory |
Router | $router |
mixed | $validatedBody |
array null | $validatedParams |
Definition at line 9 of file Handler.php.
|
abstract |
Execute the handler.
This is called after parameter validation. The return value can either be a Response or any type accepted by ResponseFactory::createFromReturnValue().
To automatically construct an error response, execute() should throw a RestException. Such exceptions will not be logged like a normal exception.
If execute() throws any other kind of exception, the exception will be logged and a generic 500 error page will be shown.
Reimplemented in MediaWiki\Rest\SimpleHandler.
MediaWiki\Rest\Handler::getBodyValidator | ( | $contentType | ) |
Fetch the BodyValidator.
string | $contentType | Content type of the request. |
Definition at line 121 of file Handler.php.
Referenced by MediaWiki\Rest\Validator\Validator\validateBody().
MediaWiki\Rest\Handler::getConfig | ( | ) |
Get the configuration array for the current route.
The return type declaration causes it to raise a fatal error if init() has not been called.
Definition at line 73 of file Handler.php.
|
protected |
The subclass should override this to provide an ETag for the current request.
This is called before execute() in order to decide whether to send a 304.
See RFC 7232 ยง 2.3 for semantics.
Definition at line 167 of file Handler.php.
|
protected |
The subclass should override this to provide the maximum last modified timestamp for the current request.
This is called before execute() in order to decide whether to send a 304.
The timestamp can be in any format accepted by ConvertibleTimestamp, or null to indicate that the timestamp is unknown.
Definition at line 154 of file Handler.php.
MediaWiki\Rest\Handler::getParamSettings | ( | ) |
Fetch ParamValidator settings for parameters.
Every setting must include self::PARAM_SOURCE to specify which part of the request is to contain the parameter.
Reimplemented in MediaWiki\Rest\Handler\HelloHandler.
Definition at line 112 of file Handler.php.
Referenced by MediaWiki\Rest\SimpleHandler\execute().
MediaWiki\Rest\Handler::getRequest | ( | ) |
Get the current request.
The return type declaration causes it to raise a fatal error if init() has not yet been called.
Definition at line 62 of file Handler.php.
Referenced by MediaWiki\Rest\SimpleHandler\execute().
MediaWiki\Rest\Handler::getResponseFactory | ( | ) |
Get the ResponseFactory which can be used to generate Response objects.
This will raise a fatal error if init() has not been called.
Definition at line 84 of file Handler.php.
|
protected |
Get the Router.
The return type declaration causes it to raise a fatal error if init() has not yet been called.
Definition at line 52 of file Handler.php.
MediaWiki\Rest\Handler::getValidatedBody | ( | ) |
Fetch the validated body.
Definition at line 140 of file Handler.php.
MediaWiki\Rest\Handler::getValidatedParams | ( | ) |
Fetch the validated parameters.
Definition at line 131 of file Handler.php.
Referenced by MediaWiki\Rest\SimpleHandler\execute().
MediaWiki\Rest\Handler::init | ( | Router | $router, |
RequestInterface | $request, | ||
array | $config, | ||
ResponseFactory | $responseFactory | ||
) |
Initialise with dependencies from the Router.
This is called after construction.
Definition at line 39 of file Handler.php.
MediaWiki\Rest\Handler::needsReadAccess | ( | ) |
Indicates whether this route requires read rights.
The handler should override this if it does not need to read from the wiki. This is uncommon, but may be useful for login and other account management APIs.
Definition at line 180 of file Handler.php.
MediaWiki\Rest\Handler::needsWriteAccess | ( | ) |
Indicates whether this route requires write access.
The handler should override this if the route does not need to write to the database.
This should return true for routes that may require synchronous database writes. Modules that do not need such writes should also not rely on master database access, since only read queries are needed and each master DB is a single point of failure.
Reimplemented in MediaWiki\Rest\Handler\HelloHandler.
Definition at line 196 of file Handler.php.
MediaWiki\Rest\Handler::validate | ( | Validator | $restValidator | ) |
Validate the request parameters/attributes and body.
If there is a validation failure, a response with an error message should be returned or an HttpException should be thrown.
Validator | $restValidator |
HttpException | On validation failure. |
Definition at line 96 of file Handler.php.
References MediaWiki\Rest\Validator\Validator\validateBody(), and MediaWiki\Rest\Validator\Validator\validateParams().
|
private |
Definition at line 24 of file Handler.php.
|
private |
Definition at line 21 of file Handler.php.
|
private |
Definition at line 27 of file Handler.php.
|
private |
Definition at line 18 of file Handler.php.
|
private |
Definition at line 33 of file Handler.php.
|
private |
Definition at line 30 of file Handler.php.
Referenced by MediaWiki\Rest\SimpleHandler\execute().
const MediaWiki\Rest\Handler::PARAM_SOURCE = 'rest-param-source' |
(string) ParamValidator constant to specify the source of the parameter.
Value must be 'path', 'query', or 'post'.
Definition at line 15 of file Handler.php.
Referenced by MediaWiki\Rest\SimpleHandler\execute(), and MediaWiki\Rest\Validator\Validator\validateParams().