MediaWiki REL1_37
|
Handler class for Core REST API endpoint that handles basic search. More...
Public Member Functions | |
__construct (Config $config, SearchEngineFactory $searchEngineFactory, SearchEngineConfig $searchEngineConfig, PermissionManager $permissionManager) | |
execute () | |
getParamSettings () | |
Fetch ParamValidator settings for parameters. | |
needsWriteAccess () | |
Indicates whether this route requires write access. | |
Public Member Functions inherited from MediaWiki\Rest\Handler | |
applyConditionalResponseHeaders (ResponseInterface $response) | |
Modify the response, adding Last-Modified and ETag headers as indicated the values previously returned by ETag and getLastModified(). | |
checkPreconditions () | |
Check the conditional request headers and generate a response if appropriate. | |
getAuthority () | |
Get the current acting authority. | |
getBodyValidator ( $contentType) | |
Fetch the BodyValidator. | |
getConfig () | |
Get the configuration array for the current route. | |
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, Authority $authority, ResponseFactory $responseFactory, HookContainer $hookContainer) | |
Initialise with dependencies from the Router. | |
needsReadAccess () | |
Indicates whether this route requires read rights. | |
validate (Validator $restValidator) | |
Validate the request parameters/attributes and body. | |
Public Attributes | |
const | COMPLETION_MODE = 'completion' |
Search title completion matches. | |
const | FULLTEXT_MODE = 'fulltext' |
Search page body and titles. | |
Public Attributes inherited from MediaWiki\Rest\Handler | |
const | PARAM_SOURCE = 'rest-param-source' |
(string) ParamValidator constant to specify the source of the parameter. | |
Protected Member Functions | |
postInitSetup () | |
The handler can override this to do any necessary setup after init() is called to inject the dependencies. | |
Protected Member Functions inherited from MediaWiki\Rest\Handler | |
getConditionalHeaderUtil () | |
Get a ConditionalHeaderUtil object. | |
getETag () | |
The subclass should override this to provide an ETag for the current request. | |
getHookContainer () | |
Get a HookContainer, for running extension hooks or for hook metadata. | |
getHookRunner () | |
Get a HookRunner for running core hooks. | |
getLastModified () | |
The subclass should override this to provide the maximum last modified timestamp for the current request. | |
getRouter () | |
Get the Router. | |
getRouteUrl ( $pathParams=[], $queryParams=[]) | |
Get the URL of this handler's endpoint. | |
hasRepresentation () | |
The subclass should override this to indicate whether the resource exists. | |
postValidationSetup () | |
The handler can override this to do any necessary setup after validate() has been called. | |
urlEncodeTitle ( $title) | |
URL-encode titles in a "pretty" way. | |
Private Member Functions | |
buildDescriptionsFromPageIdentities (array $pageIdentities) | |
Turn page info into serializable array with description field for the page. | |
buildPageInfosFromSearchResults (array $searchResults) | |
Remove duplicate pages and turn search results into array with information needed for further processing: pageId => [ $title, null, $result ]. | |
buildPageInfosFromSuggestions (array $suggestions) | |
Remove duplicate pages and turn suggestions into array with information needed for further processing: pageId => [ $title, $suggestion, null ]. | |
buildResultFromPageInfos (array $pageInfos) | |
Turn array of page info into serializable array with common information about the page. | |
buildThumbnailsFromPageIdentities (array $pageIdentities) | |
Turn page info into serializable array with thumbnail information for the page. | |
createSearchEngine () | |
doSearch ( $searchEngine) | |
Execute search and return info about pages for further processing. | |
getSearchResultsOrThrow ( $results) | |
Get SearchResults when results are either SearchResultSet or Status objects. | |
serializeThumbnail (?SearchResultThumbnail $thumbnail) | |
Converts SearchResultThumbnail object into serializable array. | |
Private Attributes | |
int null | $completionCacheExpiry |
Expiry time for use as max-age value in the cache-control header of completion search responses. | |
string | $mode = null |
PermissionManager | $permissionManager |
SearchEngineConfig | $searchEngineConfig |
SearchEngineFactory | $searchEngineFactory |
const | LIMIT = 50 |
Limit results to 50 pages per default. | |
const | MAX_LIMIT = 100 |
Hard limit results to 100 pages. | |
const | OFFSET = 0 |
Default to first page. | |
const | SUPPORTED_MODES = [ self::FULLTEXT_MODE, self::COMPLETION_MODE ] |
Supported modes. | |
Handler class for Core REST API endpoint that handles basic search.
Definition at line 28 of file SearchHandler.php.
MediaWiki\Rest\Handler\SearchHandler::__construct | ( | Config | $config, |
SearchEngineFactory | $searchEngineFactory, | ||
SearchEngineConfig | $searchEngineConfig, | ||
PermissionManager | $permissionManager | ||
) |
Config | $config | |
SearchEngineFactory | $searchEngineFactory | |
SearchEngineConfig | $searchEngineConfig | |
PermissionManager | $permissionManager |
Definition at line 82 of file SearchHandler.php.
References MediaWiki\Rest\Handler\$config, MediaWiki\Rest\Handler\SearchHandler\$permissionManager, MediaWiki\Rest\Handler\SearchHandler\$searchEngineConfig, and MediaWiki\Rest\Handler\SearchHandler\$searchEngineFactory.
|
private |
Turn page info into serializable array with description field for the page.
The information about description should be provided by extension by implementing 'SearchResultProvideDescription' hook. Description is set to null if no extensions implement the hook.
ProperPageIdentity[] | $pageIdentities |
Definition at line 282 of file SearchHandler.php.
|
private |
Remove duplicate pages and turn search results into array with information needed for further processing: pageId => [ $title, null, $result ].
SearchResult[] | $searchResults |
Definition at line 213 of file SearchHandler.php.
References $title, and getAuthority().
Referenced by MediaWiki\Rest\Handler\SearchHandler\doSearch().
|
private |
Remove duplicate pages and turn suggestions into array with information needed for further processing: pageId => [ $title, $suggestion, null ].
SearchSuggestion[] | $suggestions |
Definition at line 187 of file SearchHandler.php.
References $title, and MediaWiki\Rest\Handler\getAuthority().
Referenced by MediaWiki\Rest\Handler\SearchHandler\doSearch().
|
private |
Turn array of page info into serializable array with common information about the page.
array[] | $pageInfos |
Definition at line 237 of file SearchHandler.php.
References $title.
|
private |
Turn page info into serializable array with thumbnail information for the page.
The information about thumbnail should be provided by extension by implementing 'SearchResultProvideThumbnail' hook. Thumbnail is set to null if no extensions implement the hook.
ProperPageIdentity[] | $pageIdentities |
Definition at line 303 of file SearchHandler.php.
|
private |
Definition at line 110 of file SearchHandler.php.
References MediaWiki\Rest\Handler\getValidatedParams().
|
private |
Execute search and return info about pages for further processing.
SearchEngine | $searchEngine |
LocalizedHttpException |
Definition at line 160 of file SearchHandler.php.
References MediaWiki\Rest\Handler\SearchHandler\buildPageInfosFromSearchResults(), MediaWiki\Rest\Handler\SearchHandler\buildPageInfosFromSuggestions(), MediaWiki\Rest\Handler\SearchHandler\getSearchResultsOrThrow(), and MediaWiki\Rest\Handler\getValidatedParams().
MediaWiki\Rest\Handler\SearchHandler::execute | ( | ) |
LocalizedHttpException |
Reimplemented from MediaWiki\Rest\Handler.
Definition at line 317 of file SearchHandler.php.
References $title.
MediaWiki\Rest\Handler\SearchHandler::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.
Can be used for validating parameters inside an application/x-www-form-urlencoded or multipart/form-data POST body (i.e. parameters which would be present in PHP's $_POST array). For validating other kinds of request bodies, override getBodyValidator().
Reimplemented from MediaWiki\Rest\Handler.
Definition at line 353 of file SearchHandler.php.
|
private |
Get SearchResults when results are either SearchResultSet or Status objects.
ISearchResultSet | Status | null | $results |
LocalizedHttpException |
Definition at line 129 of file SearchHandler.php.
Referenced by MediaWiki\Rest\Handler\SearchHandler\doSearch().
MediaWiki\Rest\Handler\SearchHandler::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 primary database access, since only read queries are needed and each primary DB is a single point of failure.
Reimplemented from MediaWiki\Rest\Handler.
Definition at line 119 of file SearchHandler.php.
|
protected |
The handler can override this to do any necessary setup after init() is called to inject the dependencies.
Reimplemented from MediaWiki\Rest\Handler.
Definition at line 96 of file SearchHandler.php.
References MediaWiki\Rest\Handler\SearchHandler\FULLTEXT_MODE, and MediaWiki\Rest\Handler\getConfig().
|
private |
Converts SearchResultThumbnail object into serializable array.
SearchResultThumbnail | null | $thumbnail |
Definition at line 257 of file SearchHandler.php.
|
private |
Expiry time for use as max-age value in the cache-control header of completion search responses.
Definition at line 74 of file SearchHandler.php.
|
private |
Definition at line 57 of file SearchHandler.php.
|
private |
Definition at line 37 of file SearchHandler.php.
Referenced by MediaWiki\Rest\Handler\SearchHandler\__construct().
|
private |
Definition at line 34 of file SearchHandler.php.
Referenced by MediaWiki\Rest\Handler\SearchHandler\__construct().
|
private |
Definition at line 31 of file SearchHandler.php.
Referenced by MediaWiki\Rest\Handler\SearchHandler\__construct().
const MediaWiki\Rest\Handler\SearchHandler::COMPLETION_MODE = 'completion' |
Search title completion matches.
Definition at line 47 of file SearchHandler.php.
const MediaWiki\Rest\Handler\SearchHandler::FULLTEXT_MODE = 'fulltext' |
Search page body and titles.
Definition at line 42 of file SearchHandler.php.
Referenced by MediaWiki\Rest\Handler\SearchHandler\postInitSetup().
|
private |
Limit results to 50 pages per default.
Definition at line 60 of file SearchHandler.php.
|
private |
Hard limit results to 100 pages.
Definition at line 63 of file SearchHandler.php.
|
private |
Default to first page.
Definition at line 66 of file SearchHandler.php.
|
private |
Supported modes.
Definition at line 52 of file SearchHandler.php.