BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
ApiErrorFormatter Class Reference
Inheritance diagram for ApiErrorFormatter:

Public Member Functions

 __construct (ApiResult $result, Language $lang, $format, $useDB=false)
 
 addWarning ($moduleName, $msg, $code=null, $data=null)
 
 addError ($moduleName, $msg, $code=null, $data=null)
 
 addMessagesFromStatus ($moduleName, Status $status, $types=[ 'warning', 'error'])
 
 arrayFromStatus (Status $status, $type= 'error', $format=null)
 

Protected Member Functions

 getDummyTitle ()
 
 addWarningOrError ($tag, $moduleName, $msg)
 

Protected Attributes

 $result
 
 $lang
 
 $useDB = false
 
 $format = 'none'
 

Detailed Description

Formats errors and warnings for the API, and add them to the associated ApiResult.

Since
1.25

Constructor & Destructor Documentation

ApiErrorFormatter::__construct ( ApiResult  $result,
Language  $lang,
  $format,
  $useDB = false 
)
Parameters
ApiResult$resultInto which data will be added
Language$langUsed for i18n
string$format
  • text: Error message as wikitext
  • html: Error message as HTML
  • raw: Raw message key and parameters, no human-readable text
  • none: Code and data only, no human-readable text
bool$useDBWhether to use local translations for errors and warnings.

Member Function Documentation

ApiErrorFormatter::addError (   $moduleName,
  $msg,
  $code = null,
  $data = null 
)

Add an error to the result

Parameters
string$moduleName
MessageSpecifier | array | string$msgi18n message for the error
string$codeMachine-readable code for the warning. Defaults as for IApiMessage::getApiCode().
array$dataMachine-readable data for the warning, if any. Uses IApiMessage::getApiData() if $msg implements that interface.
ApiErrorFormatter::addMessagesFromStatus (   $moduleName,
Status  $status,
  $types = [ 'warning',
'error']   
)

Add warnings and errors from a Status object to the result

Parameters
string$moduleName
Status$status
string[]$types 'warning' and/or 'error'
ApiErrorFormatter::addWarning (   $moduleName,
  $msg,
  $code = null,
  $data = null 
)

Add a warning to the result

Parameters
string$moduleName
MessageSpecifier | array | string$msgi18n message for the warning
string$codeMachine-readable code for the warning. Defaults as for IApiMessage::getApiCode().
array$dataMachine-readable data for the warning, if any. Uses IApiMessage::getApiData() if $msg implements that interface.
ApiErrorFormatter::addWarningOrError (   $tag,
  $moduleName,
  $msg 
)
protected

Actually add the warning or error to the result

Parameters
string$tag'warning' or 'error'
string$moduleName
ApiMessage | ApiRawMessage$msg
ApiErrorFormatter::arrayFromStatus ( Status  $status,
  $type = 'error',
  $format = null 
)

Format messages from a Status as an array

Parameters
Status$status
string$type'warning' or 'error'
string | null$format
Returns
array
ApiErrorFormatter::getDummyTitle ( )
protected

Fetch a dummy title to set on Messages

Returns
Title

The documentation for this class was generated from the following file: