Debian Codegraph @

includes/OutputTransform/Stages/HydrateHeaderPlaceholders.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\OutputTransform\Stages;
4
5 use MediaWiki\OutputTransform\ContentTextTransformStage;
6 use MediaWiki\Parser\ParserOptions;
7 use MediaWiki\Parser\ParserOutput;
8
9 /**
10 * Hydrate slot section header placeholders generated by RevisionRenderer.
11 * @internal
12 */
13 class HydrateHeaderPlaceholders extends ContentTextTransformStage {
14
15 public function shouldRun( ParserOutput $po, ?ParserOptions $popts, array $options = [] ): bool {
16 // If this method ever returns something else than unconditional "true",
17 // HydrateHeaderPlaceholderTest::provideShouldNotRun should be updated to not be skipped.
18 return true;
19 }
20
21 protected function transformText( string $text, ParserOutput $po, ?ParserOptions $popts, array &$options ): string {
22 return preg_replace_callback( '#<mw:slotheader>(.*?)</mw:slotheader>#', static function ( $m ) {
23 $role = htmlspecialchars_decode( $m[1] );
24 // TODO: map to message, using the interface language. Set lang="xyz" accordingly.
25 $headerText = $role;
26
27 return $headerText;
28 }, $text );
29 }
30 }