1 | <?php |
||
38 | class ParserRequest { |
||
39 | /** |
||
40 | * @var string[] $attributes |
||
41 | */ |
||
42 | private $attributes; |
||
43 | |||
44 | /** |
||
45 | * @var string $input |
||
46 | */ |
||
47 | private $input; |
||
48 | |||
49 | /** |
||
50 | * @var \PPFrame $frame |
||
51 | */ |
||
52 | private $frame; |
||
53 | |||
54 | /** |
||
55 | * @var \Parser $parser |
||
56 | */ |
||
57 | private $parser; |
||
58 | |||
59 | /** |
||
60 | * ParserRequest constructor. |
||
61 | * |
||
62 | * Do not instantiate directly, but use {@see ApplicationFactory::getNewParserRequest} |
||
63 | * instead. |
||
64 | * |
||
65 | * @param array $argumentsPassedByParser |
||
66 | * @param bool $isParserFunction |
||
67 | * @param string $componentName |
||
68 | * |
||
69 | * @see ApplicationFactory::getNewParserRequest |
||
70 | * |
||
71 | * @throws MWException |
||
72 | */ |
||
73 | 36 | public function __construct( $argumentsPassedByParser, $isParserFunction, $componentName = 'unknown' ) { |
|
81 | |||
82 | /** |
||
83 | * Returns the tag attributes / parser function options supplies by the parser. |
||
84 | * |
||
85 | * @return string[] associative array `attribute => value` |
||
86 | */ |
||
87 | 23 | public function getAttributes() { |
|
90 | |||
91 | /** |
||
92 | * Gets the input supplied by the parser. For tag extensions this is the string between opening and closing tag. For |
||
93 | * parser functions this is the first option after the double colon. |
||
94 | * |
||
95 | * <code> |
||
96 | * <bootstrap_panel>This is the input</bootstrap_panel> |
||
97 | * {{#bootstrap_icon:This is the input}} |
||
98 | * </code> |
||
99 | * |
||
100 | * @return string |
||
101 | */ |
||
102 | 23 | public function getInput() { |
|
105 | |||
106 | /** |
||
107 | * Tag extensions supply a frame. |
||
108 | * |
||
109 | * @return \PPFrame |
||
110 | */ |
||
111 | 23 | public function getFrame() { |
|
114 | |||
115 | /** |
||
116 | * This is the parser object passed to the parser function or the tag extension. |
||
117 | * |
||
118 | * @return \Parser |
||
119 | */ |
||
120 | 23 | public function getParser() { |
|
123 | |||
124 | /** |
||
125 | * Converts an array of values in form [0] => "name=value" into a real |
||
126 | * associative array in form [name] => value. If no = is provided, |
||
127 | * true is assumed like this: [name] => true |
||
128 | * |
||
129 | * Note: shamelessly copied, see link below |
||
130 | * |
||
131 | * @see https://www.mediawiki.org/w/index.php?title=Manual:Parser_functions&oldid=2572048 |
||
132 | * |
||
133 | * @param array $options |
||
134 | * @param string $componentName |
||
135 | * |
||
136 | * @throws MWException |
||
137 | * @return array $results |
||
138 | */ |
||
139 | 17 | private function extractParserFunctionOptions( $options, $componentName ) { |
|
155 | |||
156 | /** |
||
157 | * @param string $option |
||
158 | * |
||
159 | * @return string[] |
||
160 | */ |
||
161 | 11 | private function getKeyValuePairFrom( $option ) { |
|
177 | |||
178 | /** |
||
179 | * Parses the arguments passed to parse() method depending on handler type |
||
180 | * (parser function or tag extension). |
||
181 | * |
||
182 | * @param array $argumentsPassedByParser |
||
183 | * @param bool $isParserFunction |
||
184 | * @param string $componentName |
||
185 | * |
||
186 | * @throws MWException if argument list does not match handler type or unknown handler type detected |
||
187 | * @return array array consisting of (string) $input, (array) $options, (Parser) $parser, and optional (PPFrame) $frame |
||
188 | */ |
||
189 | 36 | private function processArguments( $argumentsPassedByParser, $isParserFunction, $componentName ) { |
|
206 | } |