MediaWiki master
MediaWiki\Status\StatusFormatter Class Reference

Formatter for StatusValue objects. More...

Public Member Functions

 __construct (MessageLocalizer $messageLocalizer, MessageCache $messageCache)
 
 getHTML (StatusValue $status, array $options=[])
 Get the error message as HTML.
 
 getMessage (StatusValue $status, array $options=[])
 Get a bullet list of the errors as a Message object.
 
 getPsr3MessageAndContext (StatusValue $status)
 Try to convert the status to a PSR-3 friendly format.
 
 getWikiText (StatusValue $status, array $options=[])
 Get the error list as a wikitext formatted list.
 

Detailed Description

Formatter for StatusValue objects.

Since
1.42
See also
StatusValue

Definition at line 43 of file StatusFormatter.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Status\StatusFormatter::__construct ( MessageLocalizer  $messageLocalizer,
MessageCache  $messageCache 
)

Definition at line 48 of file StatusFormatter.php.

Member Function Documentation

◆ getHTML()

MediaWiki\Status\StatusFormatter::getHTML ( StatusValue  $status,
array  $options = [] 
)

Get the error message as HTML.

This is done by parsing the wikitext error message

Parameters
StatusValue$status
array$optionsAn array of options, supporting the following keys:
  • 'shortContext' (string|false|null) A short enclosing context message name, to be used when there is a single error
  • 'longContext' (string|false|null) A long enclosing context message name, for a list
  • 'lang' (string|Language|StubUserLang|null) Language to use for processing messages
  • 'cleanCallback' (callable|null) A callback for sanitizing parameter values
Returns
string

Definition at line 316 of file StatusFormatter.php.

References MediaWiki\Parser\ParserOutput\getText().

◆ getMessage()

MediaWiki\Status\StatusFormatter::getMessage ( StatusValue  $status,
array  $options = [] 
)

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.

Parameters
StatusValue$status
array$optionsAn array of options, supporting the following keys:
  • 'shortContext' (string|false|null) A short enclosing context message name, to be used when there is a single error
  • 'longContext' (string|false|null) A long enclosing context message name, for a list
  • 'lang' (string|Language|StubUserLang|null) Language to use for processing messages
  • 'cleanCallback' (callable|null) A callback for sanitizing parameter values
Returns
Message

Definition at line 153 of file StatusFormatter.php.

References StatusValue\fatal(), StatusValue\getErrors(), and StatusValue\isOK().

◆ getPsr3MessageAndContext()

MediaWiki\Status\StatusFormatter::getPsr3MessageAndContext ( StatusValue  $status)

Try to convert the status to a PSR-3 friendly format.

The output will be similar to getWikiText( false, false, 'en' ), but message parameters will be extracted into the context array with parameter names 'parameter1' etc. when possible.

Returns
array A pair of (message, context) suitable for passing to a PSR-3 logger.

Definition at line 209 of file StatusFormatter.php.

References MediaWiki\Status\StatusFormatter\getWikiText().

◆ getWikiText()

MediaWiki\Status\StatusFormatter::getWikiText ( StatusValue  $status,
array  $options = [] 
)

Get the error list as a wikitext formatted list.

Parameters
StatusValue$status
array$optionsAn array of options, supporting the following keys:
  • 'shortContext' (string|false|null) A short enclosing context message name, to be used when there is a single error
  • 'longContext' (string|false|null) A long enclosing context message name, for a list
  • 'lang' (string|Language|StubUserLang|null) Language to use for processing messages
  • 'cleanCallback' (callable|null) A callback for sanitizing parameter values
Returns
string

Definition at line 85 of file StatusFormatter.php.

References StatusValue\fatal(), StatusValue\getErrors(), and StatusValue\isOK().

Referenced by MediaWiki\Status\StatusFormatter\getPsr3MessageAndContext().


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