MediaWiki  master
Preprocessor.php
Go to the documentation of this file.
1 <?php
27 abstract class Preprocessor {
29  public const DOM_FOR_INCLUSION = 1;
31  public const DOM_LANG_CONVERSION_DISABLED = 2;
33  public const DOM_UNCACHED = 4;
34 
36  public $parser;
37 
39  protected $wanCache;
40 
43 
45  protected $rules = [
46  '{' => [
47  'end' => '}',
48  'names' => [
49  2 => 'template',
50  3 => 'tplarg',
51  ],
52  'min' => 2,
53  'max' => 3,
54  ],
55  '[' => [
56  'end' => ']',
57  'names' => [ 2 => null ],
58  'min' => 2,
59  'max' => 2,
60  ],
61  '-{' => [
62  'end' => '}-',
63  'names' => [ 2 => null ],
64  'min' => 2,
65  'max' => 2,
66  ],
67  ];
68 
75  public function __construct(
78  array $options = []
79  ) {
80  $this->parser = $parser;
81  $this->wanCache = $wanCache ?: WANObjectCache::newEmpty();
82  $this->disableLangConversion = !empty( $options['disableLangConversion'] );
83  }
84 
95  public function resetParser( ?Parser $parser ) {
96  // @phan-suppress-next-line PhanPossiblyNullTypeMismatchProperty For internal use only
97  $this->parser = $parser;
98  }
99 
105  abstract public function newFrame();
106 
115  abstract public function newCustomFrame( $args );
116 
124  abstract public function newPartNodeArray( $values );
125 
145  abstract public function preprocessToObj( $text, $flags = 0 );
146 }
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
Definition: Parser.php:107
preprocessToObj( $text, $flags=0)
Get the document object model for the given wikitext.
const DOM_UNCACHED
Preprocessor cache bypass flag for Preprocessor::preprocessToObj.
Parser $parser
array $rules
Brace matching rules.
__construct(Parser $parser, WANObjectCache $wanCache=null, array $options=[])
resetParser(?Parser $parser)
Allows resetting the internal Parser reference after Preprocessor is cloned.
newPartNodeArray( $values)
Create a new custom node for programmatic use of parameter replacement.
const DOM_LANG_CONVERSION_DISABLED
Language conversion construct omission flag for Preprocessor::preprocessToObj()
WANObjectCache $wanCache
newFrame()
Create a new top-level frame for expansion of a page.
const DOM_FOR_INCLUSION
Transclusion mode flag for Preprocessor::preprocessToObj()
bool $disableLangConversion
Whether language variant conversion is disabled.
newCustomFrame( $args)
Create a new custom frame for programmatic use of parameter replacement.
Multi-datacenter aware caching interface.
static newEmpty()
Get an instance that wraps EmptyBagOStuff.