| 1 |
<?php |
| 2 |
|
| 3 |
namespace MediaWiki\OutputTransform\Stages; |
| 4 |
|
| 5 |
use MediaWiki\Config\ServiceOptions; |
| 6 |
use MediaWiki\HookContainer\HookContainer; |
| 7 |
use MediaWiki\HookContainer\HookRunner; |
| 8 |
use MediaWiki\OutputTransform\ContentTextTransformStage; |
| 9 |
use MediaWiki\Parser\ParserOptions; |
| 10 |
use MediaWiki\Parser\ParserOutput; |
| 11 |
use Psr\Log\LoggerInterface; |
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
class ExecutePostCacheTransformHooks extends ContentTextTransformStage { |
| 18 |
|
| 19 |
private HookContainer $hookContainer; |
| 20 |
private HookRunner $hookRunner; |
| 21 |
|
| 22 |
public function __construct( |
| 23 |
ServiceOptions $options, LoggerInterface $logger, HookContainer $hookContainer |
| 24 |
) { |
| 25 |
parent::__construct( $options, $logger ); |
| 26 |
$this->hookRunner = new HookRunner( $hookContainer ); |
| 27 |
$this->hookContainer = $hookContainer; |
| 28 |
} |
| 29 |
|
| 30 |
public function shouldRun( ParserOutput $po, ?ParserOptions $popts, array $options = [] ): bool { |
| 31 |
return $this->hookContainer->isRegistered( 'ParserOutputPostCacheTransform' ); |
| 32 |
} |
| 33 |
|
| 34 |
protected function transformText( string $text, ParserOutput $po, ?ParserOptions $popts, array &$options |
| 35 |
): string { |
| 36 |
$this->hookRunner->onParserOutputPostCacheTransform( $po, $text, $options ); |
| 37 |
return $text; |
| 38 |
} |
| 39 |
} |