MediaWiki master
OutputTransformStage.php
Go to the documentation of this file.
1<?php
2
4
8use Psr\Log\LoggerInterface;
9
16abstract class OutputTransformStage {
18 protected LoggerInterface $logger;
19
21 public const CONSTRUCTOR_OPTIONS = [];
22
24 public function __construct( ServiceOptions $options, LoggerInterface $logger ) {
25 // Note this is static:: not self:: so we use the subclass options
26 $options->assertRequiredOptions( static::CONSTRUCTOR_OPTIONS );
27 $this->options = $options;
28 $this->logger = $logger;
29 }
30
39 abstract public function shouldRun( ParserOutput $po, ?ParserOptions $popts, array $options = [] ): bool;
40
51 abstract public function transform( ParserOutput $po, ?ParserOptions $popts, array &$options ): ParserOutput;
52}
A class for passing options to services.
assertRequiredOptions(array $expectedKeys)
Assert that the list of options provided in this instance exactly match $expectedKeys,...
Classes implementing the OutputTransformStage aim at being added to a pipeline of transformations tha...
shouldRun(ParserOutput $po, ?ParserOptions $popts, array $options=[])
Decides whether or not the stage should be run.
__construct(ServiceOptions $options, LoggerInterface $logger)
transform(ParserOutput $po, ?ParserOptions $popts, array &$options)
Transforms the input ParserOutput into the returned ParserOutput.
ParserOutput is a rendering of a Content object or a message.
Set options of the Parser.