MediaWiki  master
ContentTransformer.php
Go to the documentation of this file.
1 <?php
3 
4 use Content;
8 use ParserOptions;
9 
18 
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 }
Content\getContentHandler
getContentHandler()
Convenience method that returns the ContentHandler singleton for handling the content model that this...
ParserOptions
Set options of the Parser.
Definition: ParserOptions.php:45
MediaWiki\Content\Transform\PreSaveTransformParamsValue
Definition: PreSaveTransformParamsValue.php:12
Page\PageReference
Interface for objects (potentially) representing a page that can be viewable and linked to on a wiki.
Definition: PageReference.php:49
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
Definition: UserIdentity.php:39
MediaWiki\Content\Transform\ContentTransformer\preSaveTransform
preSaveTransform(Content $content, PageReference $page, UserIdentity $user, ParserOptions $parserOptions)
Returns a Content object with pre-save transformations applied (or $content if no transformations app...
Definition: ContentTransformer.php:37
MediaWiki\Content\Transform\PreloadTransformParamsValue
Definition: PreloadTransformParamsValue.php:11
MediaWiki\Content\Transform\ContentTransformer
A service to transform content.
Definition: ContentTransformer.php:15
MediaWiki\Content\Transform\ContentTransformer\preloadTransform
preloadTransform(Content $content, PageReference $page, ParserOptions $parserOptions, array $params=[])
Returns a Content object with preload transformations applied (or $content if no transformations appl...
Definition: ContentTransformer.php:60
$content
$content
Definition: router.php:76
MediaWiki\Content\IContentHandlerFactory
Definition: IContentHandlerFactory.php:10
Content
Base interface for content objects.
Definition: Content.php:35
MediaWiki\Content\Transform\ContentTransformer\__construct
__construct(IContentHandlerFactory $contentHandlerFactory)
Definition: ContentTransformer.php:22
MediaWiki\Content\Transform\ContentTransformer\$contentHandlerFactory
IContentHandlerFactory $contentHandlerFactory
Definition: ContentTransformer.php:17
MediaWiki\Content\Transform
Definition: ContentTransformer.php:2