MediaWiki master
OutputTransformPipeline.php
Go to the documentation of this file.
1<?php
2
4
9
14
16 private array $stages = [];
17
19 $this->stages[] = $stage;
20 return $this;
21 }
22
63 public function run( ParserOutput $in, ?ParserOptions $popts, array $options ): ParserOutput {
64 // Initialize some $options from the ParserOutput
65 $options += [
66 'enableSectionEditLinks' => !$in->getOutputFlag( ParserOutputFlags::NO_SECTION_EDIT_LINKS ),
67 'wrapperDivClass' => $in->getWrapperDivClass(),
68 'isParsoidContent' => PageBundleParserOutputConverter::hasPageBundle( $in ),
69 ];
70 if ( $options['allowClone'] ?? true ) {
71 $out = clone $in;
72 } else {
73 // T353257: This should be a clone, but we've need to suppress it
74 // for some legacy codepaths.
75 $out = $in;
76 }
77 foreach ( $this->stages as $stage ) {
78 if ( $stage->shouldRun( $out, $popts, $options ) ) {
79 // Some stages may (for now) modify $options. See OutputTransformStage documentation for more info.
80 $out = $stage->transform( $out, $popts, $options );
81 }
82 }
83 return $out;
84 }
85}
run(ParserOutput $in, ?ParserOptions $popts, array $options)
Runs the pipeline on the ParserOutput, yielding a transformed ParserOutput.
Classes implementing the OutputTransformStage aim at being added to a pipeline of transformations tha...
Set options of the Parser.
ParserOutput is a rendering of a Content object or a message.
Provides methods for conversion between PageBundle and ParserOutput TODO: Convert to a trait once we ...