Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Repo\ParserOutput\TextInjector Class Reference

Helper for injecting text by substituting placeholders. More...

Public Member Functions

 __construct (array $markers=[])
 
 newMarker ( $name)
 Associates a new marker with the given parameters, and returns it.
 
 getMarkers ()
 
 inject ( $html, $callback)
 Replaces the markers in $html by calling $callback for each marker in $markers, passing the arguments associated with each marker to $callback.
 

Private Attributes

 $uniqPrefix
 
 $markerIndex
 
 $markers
 

Detailed Description

Helper for injecting text by substituting placeholders.

This class is designed to aid with the technique of putting placeholders into cacheable HTML (in ParserOutput), and later replacing it with non-cacheable HTML snippets (for use by OutputPage).

Author
Daniel Kinzler

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\ParserOutput\TextInjector::__construct ( array  $markers = [])
Parameters
array[]$markersMarkers generated by another instance of TextInjector, for use by inject(); a map of string markers associated with parameter arrays.

Member Function Documentation

◆ getMarkers()

Wikibase\Repo\ParserOutput\TextInjector::getMarkers ( )
Returns
array[] Array mapping marker names to arrays of callback arguments.

◆ inject()

Wikibase\Repo\ParserOutput\TextInjector::inject (   $html,
  $callback 
)

Replaces the markers in $html by calling $callback for each marker in $markers, passing the arguments associated with each marker to $callback.

Parameters
string$html
callable$callback
Returns
string HTML

◆ newMarker()

Wikibase\Repo\ParserOutput\TextInjector::newMarker (   $name)

Associates a new marker with the given parameters, and returns it.

All parameters passed to this function will be associated with the marker.

Parameters
string$name
Returns
string

Member Data Documentation

◆ $markerIndex

Wikibase\Repo\ParserOutput\TextInjector::$markerIndex
private

◆ $markers

Wikibase\Repo\ParserOutput\TextInjector::$markers
private

◆ $uniqPrefix

Wikibase\Repo\ParserOutput\TextInjector::$uniqPrefix
private

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