Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Lib\Formatters\MessageSnakFormatter Class Reference

MessageSnakFormatter returns the same (localized) message for all snaks. More...

+ Inheritance diagram for Wikibase\Lib\Formatters\MessageSnakFormatter:
+ Collaboration diagram for Wikibase\Lib\Formatters\MessageSnakFormatter:

Public Member Functions

 __construct ( $snakType, Message $message, $format)
 
 getFormat ()
 
 formatSnak (Snak $snak)
 Returns a string from the message provided to the constructor.
 

Private Attributes

 $format
 
 $message
 
 $snakType
 

Static Private Attributes

static $snakTypeCssClasses
 

Additional Inherited Members

- Public Attributes inherited from Wikibase\Lib\Formatters\SnakFormatter
const OPT_LANG = ValueFormatter::OPT_LANG
 Options key for controlling the output language.
 
const FORMAT_PLAIN = 'text/plain'
 Output format types.
 
const FORMAT_WIKI = 'text/x-wiki'
 
const FORMAT_HTML = 'text/html'
 
const FORMAT_HTML_DIFF = 'text/html; disposition=diff'
 
const FORMAT_HTML_VERBOSE = 'text/html; disposition=verbose'
 
const FORMAT_HTML_VERBOSE_PREVIEW = 'text/html; disposition=verbose-preview'
 
const OPT_ON_ERROR = 'on-error'
 Options key for controlling error handling.
 
const ON_ERROR_WARN = 'warn'
 Value for the OPT_ON_ERROR option indicating that recoverable errors should cause a warning to be show to the user.
 
const ON_ERROR_FAIL = 'fail'
 Value for the OPT_ON_ERROR option indicating that recoverable errors should cause the formatting to fail with an exception.
 

Detailed Description

MessageSnakFormatter returns the same (localized) message for all snaks.

This is useful in cases where the output shall solely depend on the snak type, e.g. for PropertyNoValueSnak or PropertySomeValueSnak.

Author
Daniel Kinzler
Thiemo Kreuz

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Lib\Formatters\MessageSnakFormatter::__construct (   $snakType,
Message  $message,
  $format 
)
Parameters
string$snakTypeType of the snak, usually "value", "somevalue" or "novalue".
Message$message
string$formatOne of the SnakFormatter::FORMAT_... constants.
Exceptions
InvalidArgumentException

Member Function Documentation

◆ formatSnak()

Wikibase\Lib\Formatters\MessageSnakFormatter::formatSnak ( Snak  $snak)

Returns a string from the message provided to the constructor.

Depending on the desired format, the text is returned as plain, wikitext or HTML.

Note that this method does not look at the snak given. It simply returns the same message always.

See also
SnakFormatter::formatSnak
Parameters
Snak$snakUnused in this implementation.
Exceptions
RuntimeExceptionIf the requested output format is not known.
Returns
string Plain, wikitext or HTML

Implements Wikibase\Lib\Formatters\SnakFormatter.

◆ getFormat()

Wikibase\Lib\Formatters\MessageSnakFormatter::getFormat ( )
See also
SnakFormatter::getFormat
Returns
string One of the SnakFormatter::FORMAT_... constants.

Implements Wikibase\Lib\Formatters\SnakFormatter.

Member Data Documentation

◆ $format

Wikibase\Lib\Formatters\MessageSnakFormatter::$format
private

◆ $message

Wikibase\Lib\Formatters\MessageSnakFormatter::$message
private

◆ $snakType

Wikibase\Lib\Formatters\MessageSnakFormatter::$snakType
private

◆ $snakTypeCssClasses

Wikibase\Lib\Formatters\MessageSnakFormatter::$snakTypeCssClasses
staticprivate
Initial value:
= [
'somevalue' => 'wikibase-snakview-variation-somevaluesnak',
'novalue' => 'wikibase-snakview-variation-novaluesnak',
]

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