14use MediaWiki\Rest\Handler\Helper\RestStatusTrait;
31 private $apiMain =
null;
43 $this->apiMain = $apiMain;
50 if ( $this->apiMain ) {
51 return $this->apiMain;
54 $context = RequestContext::getMain();
55 $session = $context->getRequest()->getSession();
60 $fauxRequest =
new FauxRequest( [],
true, $session );
61 $fauxRequest->setSessionId( $session->getSessionId() );
64 $fauxContext->setRequest( $fauxRequest );
65 $fauxContext->setUser( $context->getUser() );
66 $fauxContext->setLanguage( $context->getLanguage() );
68 $this->apiMain =
new ApiMain( $fauxContext,
true );
69 return $this->apiMain;
80 $this->
getApiMain()->getModuleManager()->addModule(
84 'class' => get_class( $module ),
85 'factory' =>
static function () use ( $module ) {
107 foreach (
$params as $key => $value ) {
108 $request->setVal( $key, $value );
117 foreach ( $ex->
getStatusValue()->getMessages(
'error' ) as $msg ) {
118 $msg = ApiMessage::create( $msg );
129 $actionModuleResult = $apiMain->
getResult()->getResultData(
null, [
'Strip' =>
'all' ] );
184 array $actionModuleResult,
212 MessageValue::newFromSpecifier( $msg ),
219 [
'actionModuleErrorCode' => $msg->
getApiCode() ]
array $params
The job parameters.
This is the main API class, used for both external and internal processing.
getResult()
Get the ApiResult object associated with current request.
execute()
Execute api request.
Group all the pieces relevant to the context of a request into one instance.