BlueSpice MediaWiki master
|
Public Member Functions | |
__get ($name) | |
__set ($name, $value) | |
splitByErrorType () | |
getStatusValue () | |
getWikiText ($shortContext=false, $longContext=false, $lang=null) | |
getMessage ($shortContext=false, $longContext=false, $lang=null) | |
getHTML ($shortContext=false, $longContext=false, $lang=null) | |
getErrorsArray () | |
getWarningsArray () | |
__sleep () | |
__wakeup () | |
![]() | |
splitByErrorType () | |
isGood () | |
isOK () | |
getValue () | |
getErrors () | |
setOK ($ok) | |
setResult ($ok, $value=null) | |
warning ($message) | |
error ($message) | |
fatal ($message) | |
merge ($other, $overwriteValue=false) | |
getErrorsByType ($type) | |
hasMessage ($message) | |
replaceMessage ($source, $dest) | |
__toString () | |
Static Public Member Functions | |
static | wrap ($sv) |
![]() | |
static | newFatal ($message) |
static | newGood ($value=null) |
Public Attributes | |
$cleanCallback = false | |
![]() | |
$value | |
$success = [] | |
$successCount = 0 | |
$failCount = 0 | |
Protected Member Functions | |
cleanParams (array $params) | |
languageFromParam ($lang) | |
getErrorMessage ($error, $lang=null) | |
getErrorMessageArray ($errors, $lang=null) | |
getStatusArray ($type=false) | |
Additional Inherited Members | |
![]() | |
$ok = true | |
$errors = [] | |
Generic operation result class Has warning/error list, boolean status and arbitrary value
"Good" means the operation was completed with no warnings or errors.
"OK" means the operation was partially or wholly completed.
An operation which is not OK should have errors so that the user can be informed as to what went wrong. Calling the fatal() function sets an error message and simultaneously switches off the OK flag.
The recommended pattern for Status objects is to return a Status object unconditionally, i.e. both on success and on failure – so that the developer of the calling code is reminded that the function can fail, and so that a lack of error-handling will be explicit.
Status::__get | ( | $name | ) |
Status::__set | ( | $name, | |
$value | |||
) |
Change operation result Backwards compatibility logic
string | $name | |
mixed | $value |
RuntimeException |
Status::__sleep | ( | ) |
Don't save the callback when serializing, because Closures can't be serialized and we're going to clear it in __wakeup anyway.
Status::__wakeup | ( | ) |
Sanitize the callback parameter on wakeup, to avoid arbitrary execution.
|
protected |
array | $params |
|
protected |
Return the message for a single error
The code string can be used a message key with per-language versions. If $error is an array, the "params" field is a list of parameters for the message.
array | string | $error | Code string or (key: code string, params: string[]) map |
string | Language | $lang | Language to use for processing messages |
|
protected |
Status::getErrorsArray | ( | ) |
Get the list of errors (but not warnings)
Status::getHTML | ( | $shortContext = false , |
|
$longContext = false , |
|||
$lang = null |
|||
) |
Get the error message as HTML. This is done by parsing the wikitext error message
string | bool | $shortContext | A short enclosing context message name, to be used when there is a single error |
string | bool | $longContext | A long enclosing context message name, for a list |
string | Language | null | $lang | Language to use for processing messages |
Status::getMessage | ( | $shortContext = false , |
|
$longContext = false , |
|||
$lang = null |
|||
) |
Get a bullet list of the errors as a Message object.
$shortContext and $longContext can be used to wrap the error list in some text. $shortContext will be preferred when there is a single error; $longContext will be preferred when there are multiple ones. In either case, $1 will be replaced with the list of errors.
$shortContext is assumed to use $1 as an inline parameter: if there is a single item, it will not be made into a list; if there are multiple items, newlines will be inserted around the list. $longContext is assumed to use $1 as a standalone parameter; it will always receive a list.
If both parameters are missing, and there is only one error, no bullet will be added.
string|string[]|bool | $shortContext A message name or an array of message names. | |
string|string[]|bool | $longContext A message name or an array of message names. | |
string | Language | $lang | Language to use for processing messages |
|
protected |
Returns a list of status messages of the given type (or all if false)
string | bool | $type |
Status::getStatusValue | ( | ) |
Status::getWarningsArray | ( | ) |
Get the list of warnings (but not errors)
Status::getWikiText | ( | $shortContext = false , |
|
$longContext = false , |
|||
$lang = null |
|||
) |
Get the error list as a wikitext formatted list
string | bool | $shortContext | A short enclosing context message name, to be used when there is a single error |
string | bool | $longContext | A long enclosing context message name, for a list |
string | Language | $lang | Language to use for processing messages |
|
protected |
Status::splitByErrorType | ( | ) |
Splits this Status object into two new Status objects, one which contains only the error messages, and one that contains the warnings, only. The returned array is defined as: [ 0 => object(Status) # the Status with error messages, only 1 => object(Status) # The Status with warning messages, only ]
|
static |
Succinct helper method to wrap a StatusValue
This is is useful when formatting StatusValue objects:
StatusValue | Status | $sv |