Wikibase
MediaWiki Wikibase extension
Wikibase\Lib\Formatters\EscapingSnakFormatter Class Reference

EscapingSnakFormatter wraps another SnakFormatter and applies a transformation (escaping) to that formatter's output. More...

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

Public Member Functions

 __construct (string $format, SnakFormatter $formatter, callable $escapeCallback)
 
 formatSnak (Snak $snak)
 
 getFormat ()
 

Private Attributes

 $format
 
 $formatter
 
 $escapeCallback
 

Additional Inherited Members

- Public Attributes inherited from Wikibase\Lib\Formatters\SnakFormatter
const OPT_LANG = ValueFormatter::OPT_LANG
 Options key for controlling the output language. More...
 
const FORMAT_PLAIN = 'text/plain'
 Output format types. More...
 
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. More...
 
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. More...
 
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. More...
 

Detailed Description

EscapingSnakFormatter wraps another SnakFormatter and applies a transformation (escaping) to that formatter's output.

Author
Daniel Kinzler

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Lib\Formatters\EscapingSnakFormatter::__construct ( string  $format,
SnakFormatter  $formatter,
callable  $escapeCallback 
)
Parameters
string$formatOne of the SnakFormatter::FORMAT_... constants.
SnakFormatter$formatterA formatter returning plain text.
callable$escapeCallbackA callable taking plain text and returning escaped text.
Exceptions
ParameterTypeException

Member Function Documentation

◆ formatSnak()

Wikibase\Lib\Formatters\EscapingSnakFormatter::formatSnak ( Snak  $snak)
See also
SnakFormatter::formatSnak
Parameters
Snak$snak
Returns
string Typically wikitext or HTML, depending on the $escapeCallback provided.

Implements Wikibase\Lib\Formatters\SnakFormatter.

◆ getFormat()

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

Implements Wikibase\Lib\Formatters\SnakFormatter.

Member Data Documentation

◆ $escapeCallback

Wikibase\Lib\Formatters\EscapingSnakFormatter::$escapeCallback
private

◆ $format

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

◆ $formatter

Wikibase\Lib\Formatters\EscapingSnakFormatter::$formatter
private

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