mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-12-12 14:35:28 +00:00
b985813c56
Changes to the use statements done automatically via script Addition of missing use statement done manually Change-Id: Ia08d43b3973a12b8e0628c8552bee1c4b702f249
57 lines
1.3 KiB
PHP
57 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace MediaWiki\Extension\VisualEditor;
|
|
|
|
use MediaWiki\Context\RequestContext;
|
|
use MediaWiki\Permissions\Authority;
|
|
use MediaWiki\Rest\Handler\Helper\PageRestHelperFactory;
|
|
|
|
/**
|
|
* @since 1.40
|
|
*/
|
|
class VisualEditorParsoidClientFactory {
|
|
|
|
/**
|
|
* @internal For use by ServiceWiring.php only or when locating the service
|
|
*/
|
|
public const SERVICE_NAME = 'VisualEditor.ParsoidClientFactory';
|
|
|
|
private PageRestHelperFactory $pageRestHelperFactory;
|
|
|
|
public function __construct(
|
|
PageRestHelperFactory $pageRestHelperFactory
|
|
) {
|
|
$this->pageRestHelperFactory = $pageRestHelperFactory;
|
|
}
|
|
|
|
/**
|
|
* Create a ParsoidClient for accessing Parsoid.
|
|
*
|
|
* @param string|string[]|false $cookiesToForward
|
|
* @param Authority|null $performer
|
|
*
|
|
* @return ParsoidClient
|
|
*/
|
|
public function createParsoidClient(
|
|
/* Kept for compatibility with other extensions */ $cookiesToForward,
|
|
?Authority $performer = null
|
|
): ParsoidClient {
|
|
if ( $performer === null ) {
|
|
$performer = RequestContext::getMain()->getAuthority();
|
|
}
|
|
|
|
return $this->createDirectClient( $performer );
|
|
}
|
|
|
|
/**
|
|
* Create a ParsoidClient for accessing Parsoid.
|
|
*/
|
|
private function createDirectClient( Authority $performer ): ParsoidClient {
|
|
return new DirectParsoidClient(
|
|
$this->pageRestHelperFactory,
|
|
$performer
|
|
);
|
|
}
|
|
|
|
}
|