[ Index ]

PHP Cross Reference of MediaWiki-1.24.0

title

Body

[close]

/includes/ -> Status.php (summary)

Generic operation result. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

File Size: 456 lines (13 kb)
Included or required:0 times
Referenced: 1 time
Includes or requires: 0 files

Defines 1 class

Status:: (23 methods):
  newFatal()
  newGood()
  setResult()
  isGood()
  isOK()
  warning()
  error()
  fatal()
  __wakeup()
  cleanParams()
  getWikiText()
  getMessage()
  getErrorMessage()
  getHTML()
  getErrorMessageArray()
  merge()
  getErrorsArray()
  getWarningsArray()
  getStatusArray()
  getErrorsByType()
  hasMessage()
  replaceMessage()
  getValue()


Class: Status  - X-Ref

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.
newFatal( $message )   X-Ref
Factory function for fatal errors

param: string|Message $message Message name or object
return: Status

newGood( $value = null )   X-Ref
Factory function for good results

param: mixed $value
return: Status

setResult( $ok, $value = null )   X-Ref
Change operation result

param: bool $ok Whether the operation completed
param: mixed $value

isGood()   X-Ref
Returns whether the operation completed and didn't have any error or
warnings

return: bool

isOK()   X-Ref
Returns whether the operation completed

return: bool

warning( $message )   X-Ref
Add a new warning

param: string|Message $message Message name or object

error( $message )   X-Ref
Add an error, do not set fatal flag
This can be used for non-fatal errors

param: string|Message $message Message name or object

fatal( $message )   X-Ref
Add an error and set OK to false, indicating that the operation
as a whole was fatal

param: string|Message $message Message name or object

__wakeup()   X-Ref
Sanitize the callback parameter on wakeup, to avoid arbitrary execution.


cleanParams( $params )   X-Ref

param: array $params
return: array

getWikiText( $shortContext = false, $longContext = false )   X-Ref
Get the error list as a wikitext formatted list

param: string $shortContext A short enclosing context message name, to
param: string $longContext A long enclosing context message name, for a list
return: string

getMessage( $shortContext = false, $longContext = false )   X-Ref
Get the error list as a Message object

param: string|string[] $shortContext A short enclosing context message name (or an array of
param: string|string[] $longContext A long enclosing context message name (or an array of
return: Message

getErrorMessage( $error )   X-Ref
Return the message for a single error.

param: mixed $error With an array & two values keyed by
return: string

getHTML( $shortContext = false, $longContext = false )   X-Ref
Get the error message as HTML. This is done by parsing the wikitext error
message.

param: string $shortContext A short enclosing context message name, to
param: string $longContext A long enclosing context message name, for a list
return: string

getErrorMessageArray( $errors )   X-Ref
Return an array with the wikitext for each item in the array.

param: array $errors
return: array

merge( $other, $overwriteValue = false )   X-Ref
Merge another status object into this one

param: Status $other Other Status object
param: bool $overwriteValue Whether to override the "value" member

getErrorsArray()   X-Ref
Get the list of errors (but not warnings)

return: array A list in which each entry is an array with a message key as its first element.

getWarningsArray()   X-Ref
Get the list of warnings (but not errors)

return: array A list in which each entry is an array with a message key as its first element.

getStatusArray( $type )   X-Ref
Returns a list of status messages of the given type

param: string $type
return: array

getErrorsByType( $type )   X-Ref
Returns a list of status messages of the given type, with message and
params left untouched, like a sane version of getStatusArray

param: string $type
return: array

hasMessage( $message )   X-Ref
Returns true if the specified message is present as a warning or error

param: string|Message $message Message key or object to search for
return: bool

replaceMessage( $source, $dest )   X-Ref
If the specified source message exists, replace it with the specified
destination message, but keep the same parameters as in the original error.

Note, due to the lack of tools for comparing Message objects, this
function will not work when using a Message object as the search parameter.

param: Message|string $source Message key or object to search for
param: Message|string $dest Replacement message key or object
return: bool Return true if the replacement was done, false otherwise.

getValue()   X-Ref

return: mixed



Generated: Fri Nov 28 14:03:12 2014 Cross-referenced by PHPXref 0.7.1