diff --git a/extension.json b/extension.json index 21f8bdb6b8..6c8ad231fa 100644 --- a/extension.json +++ b/extension.json @@ -199,7 +199,11 @@ "visualeditor": { "class": "ApiVisualEditor", "services": [ - "UserNameUtils" + "UserNameUtils", + "Parser", + "LinkRenderer", + "UserOptionsLookup", + "WatchlistManager" ] }, "visualeditoredit": { diff --git a/includes/ApiVisualEditor.php b/includes/ApiVisualEditor.php index 3b5bcd5f8d..6ecf2d3632 100644 --- a/includes/ApiVisualEditor.php +++ b/includes/ApiVisualEditor.php @@ -4,15 +4,18 @@ * * @file * @ingroup Extensions - * @copyright 2011-2020 VisualEditor Team and others; see AUTHORS.txt + * @copyright 2011-2021 VisualEditor Team and others; see AUTHORS.txt * @license MIT */ use MediaWiki\Block\DatabaseBlock; +use MediaWiki\Linker\LinkRenderer; use MediaWiki\Logger\LoggerFactory; use MediaWiki\MediaWikiServices; use MediaWiki\Revision\RevisionRecord; use MediaWiki\User\UserNameUtils; +use MediaWiki\User\UserOptionsLookup; +use MediaWiki\Watchlist\WatchlistManager; use Wikimedia\ParamValidator\ParamValidator; class ApiVisualEditor extends ApiBase { @@ -22,15 +25,43 @@ class ApiVisualEditor extends ApiBase { /** @var UserNameUtils */ private $userNameUtils; + /** @var Parser */ + private $parser; + + /** @var LinkRenderer */ + private $linkRenderer; + + /** @var userOptionsLookup */ + private $userOptionsLookup; + + /** @var WatchlistManager */ + private $watchlistManager; + /** * @param ApiMain $main * @param string $name * @param UserNameUtils $userNameUtils + * @param Parser $parser + * @param LinkRenderer $linkRenderer + * @param UserOptionsLookup $userOptionsLookup + * @param WatchlistManager $watchlistManager */ - public function __construct( ApiMain $main, $name, UserNameUtils $userNameUtils ) { + public function __construct( + ApiMain $main, + $name, + UserNameUtils $userNameUtils, + Parser $parser, + LinkRenderer $linkRenderer, + UserOptionsLookup $userOptionsLookup, + WatchlistManager $watchlistManager + ) { parent::__construct( $main, $name ); $this->setLogger( LoggerFactory::getInstance( 'VisualEditor' ) ); $this->userNameUtils = $userNameUtils; + $this->parser = $parser; + $this->linkRenderer = $linkRenderer; + $this->userOptionsLookup = $userOptionsLookup; + $this->watchlistManager = $watchlistManager; } /** @@ -255,7 +286,7 @@ class ApiVisualEditor extends ApiBase { $eiTitle->exists() && $permissionManager->userCan( 'read', $user, $eiTitle ) ) { - $notices['editintro'] = MediaWikiServices::getInstance()->getParser()->parse( + $notices['editintro'] = $this->parser->parse( '