MediaWiki master
OutputTransformStage.php
Go to the documentation of this file.
1<?php
2declare( strict_types = 1 );
3
5
9use Psr\Log\LoggerInterface;
10
17abstract class OutputTransformStage {
19 protected LoggerInterface $logger;
20
22 public const CONSTRUCTOR_OPTIONS = [];
23
25 public function __construct( ServiceOptions $options, LoggerInterface $logger ) {
26 // Note this is static:: not self:: so we use the subclass options
27 $options->assertRequiredOptions( static::CONSTRUCTOR_OPTIONS );
28 $this->options = $options;
29 $this->logger = $logger;
30 }
31
40 abstract public function shouldRun( ParserOutput $po, ?ParserOptions $popts, array $options = [] ): bool;
41
52 abstract public function transform( ParserOutput $po, ?ParserOptions $popts, array &$options ): ParserOutput;
53}
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.
Set options of the Parser.
ParserOutput is a rendering of a Content object or a message.