MediaWiki  master
ContentRenderer.php
Go to the documentation of this file.
1 <?php
3 
4 use Content;
7 use ParserOptions;
8 use ParserOutput;
9 
17  private $contentHandlerFactory;
18 
22  public function __construct( IContentHandlerFactory $contentHandlerFactory ) {
23  $this->contentHandlerFactory = $contentHandlerFactory;
24  }
25 
37  public function getParserOutput(
39  PageReference $page,
40  ?int $revId = null,
41  ?ParserOptions $parserOptions = null,
42  bool $generateHtml = true
43  ): ParserOutput {
44  $contentHandler = $this->contentHandlerFactory->getContentHandler( $content->getModel() );
45  $cpoParams = new ContentParseParams( $page, $revId, $parserOptions, $generateHtml );
46 
47  return $contentHandler->getParserOutput( $content, $cpoParams );
48  }
49 }
__construct(IContentHandlerFactory $contentHandlerFactory)
getParserOutput(Content $content, PageReference $page, ?int $revId=null, ?ParserOptions $parserOptions=null, bool $generateHtml=true)
Returns a ParserOutput object containing information derived from this content.
Set options of the Parser.
Base interface for content objects.
Definition: Content.php:35
getContentHandler()
Convenience method that returns the ContentHandler singleton for handling the content model that this...
getModel()
Returns the ID of the content model used by this Content object.
Interface for objects (potentially) representing a page that can be viewable and linked to on a wiki.
$content
Definition: router.php:76