mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-27 15:50:29 +00:00
Use setters to initialize helpers
Use setters instead of constructing fake request data. Depends-On: I18c8bc6f5aa7c204f0faa56919bfe64026761bd4 Change-Id: I8d778c6e5d0b21f8615e3f330f63675cf51eee94
This commit is contained in:
parent
72b4f8cdbb
commit
bb66502100
|
@ -18,6 +18,7 @@ use MediaWiki\Edit\ParsoidOutputStash;
|
|||
use MediaWiki\Page\PageIdentity;
|
||||
use MediaWiki\Parser\Parsoid\HtmlTransformFactory;
|
||||
use MediaWiki\Parser\Parsoid\ParsoidOutputAccess;
|
||||
use MediaWiki\Parser\Parsoid\ParsoidRenderID;
|
||||
use MediaWiki\Permissions\Authority;
|
||||
use MediaWiki\Rest\Handler\HtmlInputTransformHelper;
|
||||
use MediaWiki\Rest\Handler\HtmlOutputRendererHelper;
|
||||
|
@ -98,14 +99,26 @@ class DirectParsoidClient implements ParsoidClient {
|
|||
$this->htmlTransformFactory
|
||||
);
|
||||
|
||||
// Fake REST params
|
||||
$params = [
|
||||
'stash' => $stash,
|
||||
'flavor' => $flavor,
|
||||
];
|
||||
// TODO: remove this once we no longer need a User object for rate limiting (T310476).
|
||||
if ( $this->performer instanceof User ) {
|
||||
$user = $this->performer;
|
||||
} else {
|
||||
$user = User::newFromIdentity( $this->performer->getUser() );
|
||||
}
|
||||
|
||||
$helper->init( $page, [], $user, $revision );
|
||||
|
||||
$helper->setStashingEnabled( $stash );
|
||||
$helper->setFlavor( $flavor );
|
||||
|
||||
if ( $revision ) {
|
||||
$helper->setRevision( $revision );
|
||||
}
|
||||
|
||||
if ( $pageLanguage ) {
|
||||
$helper->setPageLanguage( $pageLanguage );
|
||||
}
|
||||
|
||||
$user = User::newFromIdentity( $this->performer->getUser() );
|
||||
$helper->init( $page, $params, $user, $revision, $pageLanguage );
|
||||
return $helper;
|
||||
}
|
||||
|
||||
|
@ -136,15 +149,17 @@ class DirectParsoidClient implements ParsoidClient {
|
|||
$body = [
|
||||
'html' => [
|
||||
'body' => $html,
|
||||
],
|
||||
'original' => [
|
||||
'revid' => $oldid,
|
||||
'etag' => $etag,
|
||||
]
|
||||
];
|
||||
|
||||
$renderId = $etag ? ParsoidRenderID::newFromETag( $etag ) : null;
|
||||
|
||||
$helper->init( $page, $body, [], null, $pageLanguage );
|
||||
|
||||
if ( $oldid || $renderId ) {
|
||||
$helper->setOriginal( $oldid, $renderId );
|
||||
}
|
||||
|
||||
return $helper;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue