diff options
Diffstat (limited to 'www/wiki/extensions/Maps/src/Presentation/OutputFacade.php')
-rw-r--r-- | www/wiki/extensions/Maps/src/Presentation/OutputFacade.php | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/www/wiki/extensions/Maps/src/Presentation/OutputFacade.php b/www/wiki/extensions/Maps/src/Presentation/OutputFacade.php new file mode 100644 index 00000000..119f3b1d --- /dev/null +++ b/www/wiki/extensions/Maps/src/Presentation/OutputFacade.php @@ -0,0 +1,62 @@ +<?php + +namespace Maps\Presentation; + +use OutputPage; +use ParserOutput; + +class OutputFacade { + + /** + * @var OutputPage + */ + private $outputPage; + + /** + * @var ParserOutput + */ + private $parserOutput; + + public static function newFromOutputPage( OutputPage $outputPage ) { + $instance = new self(); + $instance->outputPage = $outputPage; + return $instance; + } + + public static function newFromParserOutput( ParserOutput $parserOutput ) { + $instance = new self(); + $instance->parserOutput = $parserOutput; + return $instance; + } + + public function addHtml( string $html ) { + if ( $this->outputPage !== null ) { + $this->outputPage->addHTML( $html ); + } + + if ( $this->parserOutput !== null ) { + $this->parserOutput->setText( $this->parserOutput->getRawText() . $html ); + } + } + + public function addModules( string ...$modules ) { + if ( $this->outputPage !== null ) { + $this->outputPage->addModules( $modules ); + } + + if ( $this->parserOutput !== null ) { + $this->parserOutput->addModules( $modules ); + } + } + + public function addHeadItem( string $name, string $html ) { + if ( $this->outputPage !== null ) { + $this->outputPage->addHeadItem( $name, $html ); + } + + if ( $this->parserOutput !== null ) { + $this->parserOutput->addHeadItem( $html, $name ); + } + } + +} |