2declare( strict_types = 1 );
9use Psr\Log\LoggerInterface;
10use Wikimedia\Assert\Assert;
35 private bool $exclusive =
false,
42 $domShouldRun = $this->domTransform->shouldRun( $po, $popts,
$options );
43 $textClass = $this->textTransform::class;
44 $domClass = $this->domTransform::class;
45 Assert::invariant( $this->exclusive ?
46 !( $textShouldRun && $domShouldRun ) : $textShouldRun === $domShouldRun,
47 "Bad pipeline stage definition for $textClass / $domClass"
49 return $textShouldRun || $domShouldRun;
53 $useDom = $this->exclusive ?
54 $this->domTransform->shouldRun( $po, $popts, $options ) :
55 $po->getContentHolder()->preferDom();
56 return $useDom ? $this->domTransform->transform( $po, $popts, $options ) :
57 $this->textTransform->transform( $po, $popts, $options );
OutputTransformStages that can modify the content either as a DOM tree or an HTML string.
__construct(ServiceOptions $options, LoggerInterface $logger, private OutputTransformStage &TextTransformStage $textTransform, private OutputTransformStage &DOMTransformStage $domTransform, private bool $exclusive=false,)
shouldRun(ParserOutput $po, ParserOptions $popts, array $options=[])
Decides whether or not the stage should be run.
transform(ParserOutput $po, ParserOptions $popts, array &$options)
Transforms the input ParserOutput into the returned ParserOutput.
TextTransformStage is a simple marker interface to indicate a stage that primary performs transformat...