Merge "Rest: Add Handler::postInitSetup"
This commit is contained in:
commit
666af800d7
2 changed files with 11 additions and 18 deletions
|
|
@ -43,13 +43,14 @@ abstract class Handler {
|
|||
* @param array $config
|
||||
* @param ResponseFactory $responseFactory
|
||||
*/
|
||||
public function init( Router $router, RequestInterface $request, array $config,
|
||||
final public function init( Router $router, RequestInterface $request, array $config,
|
||||
ResponseFactory $responseFactory
|
||||
) {
|
||||
$this->router = $router;
|
||||
$this->request = $request;
|
||||
$this->config = $config;
|
||||
$this->responseFactory = $responseFactory;
|
||||
$this->postInitSetup();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -270,6 +271,13 @@ abstract class Handler {
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* The handler can override this to do any necessary setup after init()
|
||||
* is called to inject the dependencies.
|
||||
*/
|
||||
protected function postInitSetup() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the handler. This is called after parameter validation. The
|
||||
* return value can either be a Response or any type accepted by
|
||||
|
|
|
|||
|
|
@ -10,10 +10,7 @@ use MediaWiki\Permissions\PermissionManager;
|
|||
use MediaWiki\Rest\Entity\SearchResultPageIdentityValue;
|
||||
use MediaWiki\Rest\Handler;
|
||||
use MediaWiki\Rest\LocalizedHttpException;
|
||||
use MediaWiki\Rest\RequestInterface;
|
||||
use MediaWiki\Rest\Response;
|
||||
use MediaWiki\Rest\ResponseFactory;
|
||||
use MediaWiki\Rest\Router;
|
||||
use MediaWiki\Search\Entity\SearchResultThumbnail;
|
||||
use RequestContext;
|
||||
use SearchEngine;
|
||||
|
|
@ -104,20 +101,8 @@ class SearchHandler extends Handler {
|
|||
$this->completionCacheExpiry = $config->get( 'SearchSuggestCacheExpiry' );
|
||||
}
|
||||
|
||||
public function init(
|
||||
Router $router,
|
||||
RequestInterface $request,
|
||||
array $config,
|
||||
ResponseFactory $responseFactory
|
||||
) {
|
||||
parent::init(
|
||||
$router,
|
||||
$request,
|
||||
$config,
|
||||
$responseFactory
|
||||
);
|
||||
|
||||
$this->mode = $config['mode'] ?? self::FULLTEXT_MODE;
|
||||
protected function postInitSetup() {
|
||||
$this->mode = $this->getConfig()['mode'] ?? self::FULLTEXT_MODE;
|
||||
|
||||
if ( !in_array( $this->mode, self::SUPPORTED_MODES ) ) {
|
||||
throw new InvalidArgumentException(
|
||||
|
|
|
|||
Loading…
Reference in a new issue