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

Decorator for SnakFormatter that handles PropertyDataTypeLookupException and MismatchingDataValueTypeException by placing the appropriate warning in the snakFormatter's output. More...

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

Public Member Functions

 __construct (SnakFormatter $snakFormatter, ?ValueFormatter $fallbackFormatter, ?string $language)
 
 formatSnak (Snak $snak)
 
 getFormat ()
 

Private Member Functions

 formatWarning ( $key,... $args)
 

Private Attributes

 $snakFormatter
 
 $fallbackFormatter
 
 $language
 

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

Decorator for SnakFormatter that handles PropertyDataTypeLookupException and MismatchingDataValueTypeException by placing the appropriate warning in the snakFormatter's output.

A fallback ValueFormatter can be used to provide basic formatting for values in the presence of snak formatting errors.

Author
Daniel Kinzler

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Lib\Formatters\ErrorHandlingSnakFormatter::__construct ( SnakFormatter $snakFormatter,
?ValueFormatter $fallbackFormatter,
?string $language )

Member Function Documentation

◆ formatSnak()

Wikibase\Lib\Formatters\ErrorHandlingSnakFormatter::formatSnak ( Snak $snak)
See also
SnakFormatter::formatSnak
Parameters
Snak$snak
Exceptions
InvalidArgumentException
FormattingException
Returns
string Either plain text, wikitext or HTML, depending on the SnakFormatter provided.

Implements Wikibase\Lib\Formatters\SnakFormatter.

◆ formatWarning()

Wikibase\Lib\Formatters\ErrorHandlingSnakFormatter::formatWarning ( $key,
$args )
private
Parameters
string$key
Returns
string Formatted warning, in the format specified by getFormat()

◆ getFormat()

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

Implements Wikibase\Lib\Formatters\SnakFormatter.

Member Data Documentation

◆ $fallbackFormatter

Wikibase\Lib\Formatters\ErrorHandlingSnakFormatter::$fallbackFormatter
private

◆ $language

Wikibase\Lib\Formatters\ErrorHandlingSnakFormatter::$language
private

◆ $snakFormatter

Wikibase\Lib\Formatters\ErrorHandlingSnakFormatter::$snakFormatter
private

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