MediaWiki  master
ContentTransformer.php
Go to the documentation of this file.
1 <?php
3 
4 use Content;
8 use ParserOptions;
9 
17  private $contentHandlerFactory;
18 
22  public function __construct( IContentHandlerFactory $contentHandlerFactory ) {
23  $this->contentHandlerFactory = $contentHandlerFactory;
24  }
25 
37  public function preSaveTransform(
39  PageReference $page,
40  UserIdentity $user,
41  ParserOptions $parserOptions
42  ): Content {
43  $contentHandler = $this->contentHandlerFactory->getContentHandler( $content->getModel() );
44  $pstParams = new PreSaveTransformParamsValue( $page, $user, $parserOptions );
45 
46  return $contentHandler->preSaveTransform( $content, $pstParams );
47  }
48 
60  public function preloadTransform(
62  PageReference $page,
63  ParserOptions $parserOptions,
64  array $params = []
65  ): Content {
66  $contentHandler = $this->contentHandlerFactory->getContentHandler( $content->getModel() );
67  $pltParams = new PreloadTransformParamsValue( $page, $parserOptions, $params );
68 
69  return $contentHandler->preloadTransform( $content, $pltParams );
70  }
71 }
__construct(IContentHandlerFactory $contentHandlerFactory)
preloadTransform(Content $content, PageReference $page, ParserOptions $parserOptions, array $params=[])
Returns a Content object with preload transformations applied (or $content if no transformations appl...
preSaveTransform(Content $content, PageReference $page, UserIdentity $user, ParserOptions $parserOptions)
Returns a Content object with pre-save transformations applied (or $content if no transformations app...
Set options of the Parser.
Base interface for representing page content.
Definition: Content.php:37
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.
Interface for objects representing user identity.
$content
Definition: router.php:76