ParsoidHelper: Make VisualEditorParsoidClientFactory required

In order to make this interface cleaner and not promote the
use of optional parameters when not needed, make the factory
required so that callers should worry about it and not overwork
the helper.

In this case, DiscussionTools extension is already using this
interface and has the factory injected appropriately.

Depends-On: If682af406c0fc7a9eca106eb3ebd95e6c14baddd
Change-Id: I836c0ad73687d8b99d1e067a5c3a3e512b4bd37a
This commit is contained in:
Derick Alangi 2022-09-06 21:16:21 +01:00
parent 8c458e78b4
commit 8bfe88b8b1

View file

@ -13,7 +13,6 @@
namespace MediaWiki\Extension\VisualEditor;
use Language;
use MediaWiki\MediaWikiServices;
use MediaWiki\Revision\RevisionRecord;
use Psr\Log\LoggerInterface;
use StatusValue;
@ -33,20 +32,16 @@ class ParsoidHelper {
/**
* @param LoggerInterface $logger
* @param string|false $forwardCookies
* @param VisualEditorParsoidClientFactory|null $clientFactory
* @param VisualEditorParsoidClientFactory $clientFactory
*/
public function __construct(
LoggerInterface $logger,
$forwardCookies,
?VisualEditorParsoidClientFactory $clientFactory = null
VisualEditorParsoidClientFactory $clientFactory
) {
$this->logger = $logger;
$this->forwardCookies = $forwardCookies;
// XXX: Extension:DiscussionTools is already instantiating this helper, so, we
// need to carter for backwards compatibility, so just fall back to creating
// from service locator.
$this->veParsoidClientFactory = $clientFactory ?? MediaWikiServices::getInstance()
->getService( VisualEditorParsoidClientFactory::SERVICE_NAME );
$this->veParsoidClientFactory = $clientFactory;
}
/**