Wikibase
MediaWiki Wikibase extension
Wikibase\Client\Usage\UsageTrackingSnakFormatter Class Reference

SnakFormatter decorator that records entity usage. More...

+ Inheritance diagram for Wikibase\Client\Usage\UsageTrackingSnakFormatter:
+ Collaboration diagram for Wikibase\Client\Usage\UsageTrackingSnakFormatter:

Public Member Functions

 __construct (SnakFormatter $snakFormatter, UsageAccumulator $usageAccumulator, EntityIdParser $repoItemUriParser, UsageTrackingLanguageFallbackLabelDescriptionLookup $usageTrackingLabelDescriptionLookup)
 
 formatSnak (Snak $snak)
 
 getFormat ()
 Returns the format ID of the format this formatter generates. More...
 

Private Member Functions

 addLabelUsage (EntityId $id)
 

Private Attributes

 $snakFormatter
 
 $usageAccumulator
 
 $repoItemUriParser
 
 $usageTrackingLabelDescriptionLookup
 

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

SnakFormatter decorator that records entity usage.

This uses an UsageTrackingLanguageFallbackLabelDescriptionLookup internally in order to track label usage.

See also
UsageAccumulator
Author
Daniel Kinzler

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Client\Usage\UsageTrackingSnakFormatter::__construct ( SnakFormatter  $snakFormatter,
UsageAccumulator  $usageAccumulator,
EntityIdParser  $repoItemUriParser,
UsageTrackingLanguageFallbackLabelDescriptionLookup  $usageTrackingLabelDescriptionLookup 
)

Member Function Documentation

◆ addLabelUsage()

Wikibase\Client\Usage\UsageTrackingSnakFormatter::addLabelUsage ( EntityId  $id)
private

◆ formatSnak()

Wikibase\Client\Usage\UsageTrackingSnakFormatter::formatSnak ( Snak  $snak)
See also
SnakFormatter::formatSnak
Parameters
Snak$snak
Returns
string Either plain text, wikitext or HTML, depending on the SnakFormatter provided.

Implements Wikibase\Lib\Formatters\SnakFormatter.

◆ getFormat()

Wikibase\Client\Usage\UsageTrackingSnakFormatter::getFormat ( )

Returns the format ID of the format this formatter generates.

This uses the FORMAT_XXX constants defined in OutputFormatSnakFormatterFactory.

Returns
string One of the SnakFormatter::FORMAT_... constants.

Implements Wikibase\Lib\Formatters\SnakFormatter.

Member Data Documentation

◆ $repoItemUriParser

Wikibase\Client\Usage\UsageTrackingSnakFormatter::$repoItemUriParser
private

◆ $snakFormatter

Wikibase\Client\Usage\UsageTrackingSnakFormatter::$snakFormatter
private

◆ $usageAccumulator

Wikibase\Client\Usage\UsageTrackingSnakFormatter::$usageAccumulator
private

◆ $usageTrackingLabelDescriptionLookup

Wikibase\Client\Usage\UsageTrackingSnakFormatter::$usageTrackingLabelDescriptionLookup
private

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