Go to the documentation of this file.
55 public static function wrap( $sv ) {
56 if ( $sv instanceof
static ) {
60 $result =
new static();
61 $result->ok =& $sv->ok;
62 $result->errors =& $sv->errors;
63 $result->value =& $sv->value;
64 $result->successCount =& $sv->successCount;
65 $result->failCount =& $sv->failCount;
66 $result->success =& $sv->success;
79 if ( $name ===
'ok' ) {
82 if ( $name ===
'errors' ) {
86 throw new RuntimeException(
"Cannot get '$name' property." );
98 if ( $name ===
'ok' ) {
100 } elseif ( !property_exists( $this, $name ) ) {
104 throw new RuntimeException(
"Cannot set '$name' property." );
121 list( $errorsOnlyStatus, $warningsOnlyStatus ) = parent::splitByErrorType();
122 $errorsOnlyStatus->cleanCallback =
125 return [ $errorsOnlyStatus, $warningsOnlyStatus ];
142 if ( !$this->cleanCallback ) {
146 foreach ( $params as $i => $param ) {
147 $cleanParams[$i] = call_user_func( $this->cleanCallback, $param );
158 if (
$lang ===
null ) {
180 if ( count( $rawErrors ) === 0 ) {
181 if ( $this->
isOK() ) {
182 $this->
fatal(
'internalerror_info',
183 __METHOD__ .
" called for a good result, this is incorrect\n" );
185 $this->
fatal(
'internalerror_info',
186 __METHOD__ .
": Invalid result object: no error text but not OK\n" );
190 if ( count( $rawErrors ) === 1 ) {
192 if ( $shortContext ) {
194 } elseif ( $longContext ) {
199 foreach (
$errors as &$error ) {
200 $error = $error->plain();
202 $s =
'* ' . implode(
"\n* ",
$errors ) .
"\n";
203 if ( $longContext ) {
205 } elseif ( $shortContext ) {
232 public function getMessage( $shortContext =
false, $longContext =
false,
$lang =
null ) {
236 if ( count( $rawErrors ) === 0 ) {
237 if ( $this->
isOK() ) {
238 $this->
fatal(
'internalerror_info',
239 __METHOD__ .
" called for a good result, this is incorrect\n" );
241 $this->
fatal(
'internalerror_info',
242 __METHOD__ .
": Invalid result object: no error text but not OK\n" );
246 if ( count( $rawErrors ) === 1 ) {
248 if ( $shortContext ) {
250 } elseif ( $longContext ) {
252 $wrapper->params(
$s )->parse();
257 $msgCount = count( $msgs );
259 $s =
new RawMessage(
'* $' . implode(
"\n* \$", range( 1, $msgCount ) ) );
260 $s->params( $msgs )->parse();
262 if ( $longContext ) {
264 } elseif ( $shortContext ) {
285 if ( is_array( $error ) ) {
286 if ( isset( $error[
'message'] ) && $error[
'message'] instanceof
Message ) {
287 $msg = $error[
'message'];
288 } elseif ( isset( $error[
'message'] ) && isset( $error[
'params'] ) ) {
290 array_map(
'wfEscapeWikiText', $this->
cleanParams( $error[
'params'] ) ) );
292 $msgName = array_shift( $error );
294 array_map(
'wfEscapeWikiText', $this->
cleanParams( $error ) ) );
296 } elseif ( is_string( $error ) ) {
299 throw new UnexpectedValueException(
'Got ' . get_class( $error ) .
' for key.' );
314 public function getHTML( $shortContext =
false, $longContext =
false,
$lang =
null ) {
319 ? $out->
getText( [
'enableSectionEditLinks' =>
false ] )
331 return array_map(
function ( $e ) use (
$lang ) {
369 foreach ( $this->
getErrors() as $error ) {
370 if (
$type ===
false || $error[
'type'] ===
$type ) {
372 $result[] = array_merge(
373 [ $error[
'message']->getKey() ],
374 $error[
'message']->getParams()
376 } elseif ( $error[
'params'] ) {
377 $result[] = array_merge( [ $error[
'message'] ], $error[
'params'] );
379 $result[] = [ $error[
'message'] ];
393 $keys = array_keys( get_object_vars( $this ) );
394 return array_diff(
$keys, [
'cleanCallback' ] );
401 $this->cleanCallback =
false;
Generic operation result class Has warning/error list, boolean status and arbitrary value.
if(!isset( $args[0])) $lang
languageFromParam( $lang)
getErrorMessage( $error, $lang=null)
Return the message for a single error.
getStatusValue()
Returns the wrapped StatusValue object.
getMessage( $shortContext=false, $longContext=false, $lang=null)
Get a bullet list of the errors as a Message object.
fatal( $message,... $parameters)
Add an error and set OK to false, indicating that the operation as a whole was fatal.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
__get( $name)
Backwards compatibility logic.
setOK( $ok)
Change operation status.
__set( $name, $value)
Change operation result Backwards compatibility logic.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
getWikiText( $shortContext=false, $longContext=false, $lang=null)
Get the error list as a wikitext formatted list.
getHTML( $shortContext=false, $longContext=false, $lang=null)
Get the error message as HTML.
static wrap( $sv)
Succinct helper method to wrap a StatusValue.
isOK()
Returns whether the operation completed.
getErrorMessageArray( $errors, $lang=null)
Return an array with a Message object for each error.
static singleton()
Get the singleton instance of this class.
__wakeup()
Sanitize the callback parameter on wakeup, to avoid arbitrary execution.
getErrors()
Get the list of errors.
Stub object for the user language.
__sleep()
Don't save the callback when serializing, because Closures can't be serialized and we're going to cle...
static getMain()
Get the RequestContext object associated with the main request.
callable false $cleanCallback
getWarningsArray()
Get the list of warnings (but not errors)
getStatusArray( $type=false)
Returns a list of status messages of the given type (or all if false)
cleanParams(array $params)
static factory( $code)
Get a cached or new language object for a given language code.
getText( $options=[])
Get the output HTML.
Variant of the Message class.
getErrorsArray()
Get the list of errors (but not warnings)
Internationalisation code.
splitByErrorType()
Splits this Status object into two new Status objects, one which contains only the error messages,...