MediaWiki
1.28.0
|
Formats errors and warnings for the API, and add them to the associated ApiResult. More...
Public Member Functions | |
__construct (ApiResult $result, Language $lang, $format, $useDB=false) | |
addError ($moduleName, $msg, $code=null, $data=null) | |
Add an error to the result. More... | |
addMessagesFromStatus ($moduleName, Status $status, $types=[ 'warning', 'error']) | |
Add warnings and errors from a Status object to the result. More... | |
addWarning ($moduleName, $msg, $code=null, $data=null) | |
Add a warning to the result. More... | |
arrayFromStatus (Status $status, $type= 'error', $format=null) | |
Format messages from a Status as an array. More... | |
Protected Member Functions | |
addWarningOrError ($tag, $moduleName, $msg) | |
Actually add the warning or error to the result. More... | |
getDummyTitle () | |
Fetch a dummy title to set on Messages. More... | |
Protected Attributes | |
$format = 'none' | |
Language | $lang |
ApiResult | $result |
$useDB = false | |
Static Private Attributes | |
static Title | $dummyTitle = null |
Dummy title to silence warnings from MessageCache::parse() More... | |
Formats errors and warnings for the API, and add them to the associated ApiResult.
Definition at line 30 of file ApiErrorFormatter.php.
ApiResult | $result | Into which data will be added |
Language | $lang | Used for i18n |
string | $format |
|
bool | $useDB | Whether to use local translations for errors and warnings. |
Definition at line 52 of file ApiErrorFormatter.php.
ApiErrorFormatter::addError | ( | $moduleName, | |
$msg, | |||
$code = null , |
|||
$data = null |
|||
) |
Add an error to the result.
string | $moduleName | |
MessageSpecifier | array | string | $msg | i18n message for the error |
string | $code | Machine-readable code for the warning. Defaults as for IApiMessage::getApiCode(). |
array | $data | Machine-readable data for the warning, if any. Uses IApiMessage::getApiData() if $msg implements that interface. |
Definition at line 96 of file ApiErrorFormatter.php.
References $code, addWarningOrError(), ApiMessage\create(), and getDummyTitle().
ApiErrorFormatter::addMessagesFromStatus | ( | $moduleName, | |
Status | $status, | ||
$types = [ 'warning' , |
|||
'error'] | |||
) |
Add warnings and errors from a Status object to the result.
string | $moduleName | |
Status | $status | |
string[] | $types 'warning' and/or 'error' |
Definition at line 110 of file ApiErrorFormatter.php.
References $args, $tag, addWarningOrError(), array(), as, ApiMessage\create(), getDummyTitle(), and StatusValue\isGood().
ApiErrorFormatter::addWarning | ( | $moduleName, | |
$msg, | |||
$code = null , |
|||
$data = null |
|||
) |
Add a warning to the result.
string | $moduleName | |
MessageSpecifier | array | string | $msg | i18n message for the warning |
string | $code | Machine-readable code for the warning. Defaults as for IApiMessage::getApiCode(). |
array | $data | Machine-readable data for the warning, if any. Uses IApiMessage::getApiData() if $msg implements that interface. |
Definition at line 79 of file ApiErrorFormatter.php.
References $code, addWarningOrError(), ApiMessage\create(), and getDummyTitle().
|
protected |
Actually add the warning or error to the result.
string | $tag | 'warning' or 'error' |
string | $moduleName | |
ApiMessage | ApiRawMessage | $msg |
Definition at line 186 of file ApiErrorFormatter.php.
References $flags, $path, $tag, $value, ApiResult\ADD_ON_TOP, format, ApiResult\META_CONTENT, ApiResult\NO_SIZE_CHECK, and ApiResult\setIndexedTagName().
Referenced by addError(), addMessagesFromStatus(), and addWarning().
ApiErrorFormatter::arrayFromStatus | ( | Status | $status, |
$type = 'error' , |
|||
$format = null |
|||
) |
Format messages from a Status as an array.
Status | $status | |
string | $type | 'warning' or 'error' |
string | null | $format |
Definition at line 162 of file ApiErrorFormatter.php.
References $format, $type, array(), format, ApiResult\getResultData(), and StatusValue\isGood().
|
protected |
Fetch a dummy title to set on Messages.
Definition at line 63 of file ApiErrorFormatter.php.
References Title\makeTitle(), and NS_SPECIAL.
Referenced by addError(), addMessagesFromStatus(), and addWarning().
|
staticprivate |
Dummy title to silence warnings from MessageCache::parse()
Definition at line 32 of file ApiErrorFormatter.php.
|
protected |
Definition at line 40 of file ApiErrorFormatter.php.
Referenced by __construct(), and arrayFromStatus().
|
protected |
Definition at line 38 of file ApiErrorFormatter.php.
Referenced by __construct().
|
protected |
Definition at line 35 of file ApiErrorFormatter.php.
Referenced by __construct(), and ApiErrorFormatter_BackCompat\arrayFromStatus().
|
protected |
Definition at line 39 of file ApiErrorFormatter.php.
Referenced by __construct().