mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-23 22:13:34 +00:00
Replace Content::preSaveTransform call to ContentTransformer::preSaveTransform
Bug: T287156 Change-Id: Ieaf645dab42c0e6def9fc36ecc619843710656f4
This commit is contained in:
parent
ea0f1c2610
commit
0519e98725
|
@ -203,7 +203,8 @@
|
|||
"Parser",
|
||||
"LinkRenderer",
|
||||
"UserOptionsLookup",
|
||||
"WatchlistManager"
|
||||
"WatchlistManager",
|
||||
"ContentTransformer"
|
||||
]
|
||||
},
|
||||
"visualeditoredit": {
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
|
||||
use MediaWiki\Block\DatabaseBlock;
|
||||
use MediaWiki\Content\Transform\ContentTransformer;
|
||||
use MediaWiki\Linker\LinkRenderer;
|
||||
use MediaWiki\Logger\LoggerFactory;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
@ -37,6 +38,9 @@ class ApiVisualEditor extends ApiBase {
|
|||
/** @var WatchlistManager */
|
||||
private $watchlistManager;
|
||||
|
||||
/** @var ContentTransformer */
|
||||
private $contentTransformer;
|
||||
|
||||
/**
|
||||
* @param ApiMain $main
|
||||
* @param string $name
|
||||
|
@ -45,6 +49,7 @@ class ApiVisualEditor extends ApiBase {
|
|||
* @param LinkRenderer $linkRenderer
|
||||
* @param UserOptionsLookup $userOptionsLookup
|
||||
* @param WatchlistManager $watchlistManager
|
||||
* @param ContentTransformer $contentTransformer
|
||||
*/
|
||||
public function __construct(
|
||||
ApiMain $main,
|
||||
|
@ -53,7 +58,8 @@ class ApiVisualEditor extends ApiBase {
|
|||
Parser $parser,
|
||||
LinkRenderer $linkRenderer,
|
||||
UserOptionsLookup $userOptionsLookup,
|
||||
WatchlistManager $watchlistManager
|
||||
WatchlistManager $watchlistManager,
|
||||
ContentTransformer $contentTransformer
|
||||
) {
|
||||
parent::__construct( $main, $name );
|
||||
$this->setLogger( LoggerFactory::getInstance( 'VisualEditor' ) );
|
||||
|
@ -62,6 +68,7 @@ class ApiVisualEditor extends ApiBase {
|
|||
$this->linkRenderer = $linkRenderer;
|
||||
$this->userOptionsLookup = $userOptionsLookup;
|
||||
$this->watchlistManager = $watchlistManager;
|
||||
$this->contentTransformer = $contentTransformer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -72,13 +79,14 @@ class ApiVisualEditor extends ApiBase {
|
|||
* @return string The transformed wikitext
|
||||
*/
|
||||
protected function pstWikitext( Title $title, $wikitext ) {
|
||||
return ContentHandler::makeContent( $wikitext, $title, CONTENT_MODEL_WIKITEXT )
|
||||
->preSaveTransform(
|
||||
$title,
|
||||
$this->getUser(),
|
||||
WikiPage::factory( $title )->makeParserOptions( $this->getContext() )
|
||||
)
|
||||
->serialize( 'text/x-wiki' );
|
||||
$content = ContentHandler::makeContent( $wikitext, $title, CONTENT_MODEL_WIKITEXT );
|
||||
return $this->contentTransformer->preSaveTransform(
|
||||
$content,
|
||||
$title,
|
||||
$this->getUser(),
|
||||
WikiPage::factory( $title )->makeParserOptions( $this->getContext() )
|
||||
)
|
||||
->serialize( 'text/x-wiki' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue