Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
n/a
0 / 0
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3namespace MediaWiki\Rest\Hook;
4
5use MediaWiki\Api\Hook\ApiCheckCanExecuteHook;
6use MediaWiki\Rest\Handler;
7use MediaWiki\Rest\HttpException;
8use MediaWiki\Rest\Module\Module;
9use MediaWiki\Rest\RequestInterface;
10
11/**
12 * This is a hook handler interface, see docs/Hooks.md.
13 * Use the hook name "RestCheckCanExecute" to register handlers implementing this interface.
14 *
15 * @ingroup Hooks
16 * @since 1.44
17 * @see ApiCheckCanExecuteHook
18 */
19interface RestCheckCanExecuteHook {
20    /**
21     * Called when initializing a REST API request. Use this hook to deny requests to API
22     * endpoints belonging to a different component than the hook handler.
23     *
24     * @param Module $module The module responsible for processing the request. (When the handler
25     *   does not belong to a module, this will be an ExtraRoutesModule instance.)
26     * @param Handler $handler The handler responsible for processing the request.
27     * @param string $path Path of the request. When the handler belongs to a module, doesn't
28     *   include the module prefix.
29     * @param RequestInterface $request
30     * @param HttpException|null &$error Set this to explain why the request cannot be executed.
31     *   Should only be set when returning false.
32     * @return bool Return false to block request execution. $error must be set.
33     */
34    public function onRestCheckCanExecute(
35        Module $module,
36        Handler $handler,
37        string $path,
38        RequestInterface $request,
39        ?HttpException &$error
40    ): bool;
41}