Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| ParsoidClientFactory | |
100.00% |
4 / 4 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| createParsoidClient | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| createDirectClient | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace ContentTranslation; |
| 4 | |
| 5 | use MediaWiki\Context\RequestContext; |
| 6 | use MediaWiki\Rest\Handler\Helper\PageRestHelperFactory; |
| 7 | |
| 8 | class ParsoidClientFactory { |
| 9 | |
| 10 | /** |
| 11 | * @internal For use by ServiceWiring.php only or when locating the service |
| 12 | */ |
| 13 | public const SERVICE_NAME = 'ContentTranslation.ParsoidClientFactory'; |
| 14 | |
| 15 | public function __construct( private readonly PageRestHelperFactory $pageRestHelperFactory ) { |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * Create a ParsoidClient for accessing Parsoid. |
| 20 | */ |
| 21 | public function createParsoidClient(): ParsoidClient { |
| 22 | return $this->createDirectClient(); |
| 23 | } |
| 24 | |
| 25 | /** |
| 26 | * Create a ParsoidClient for accessing Parsoid. |
| 27 | */ |
| 28 | private function createDirectClient(): ParsoidClient { |
| 29 | $performer = RequestContext::getMain()->getAuthority(); |
| 30 | return new DirectParsoidClient( $this->pageRestHelperFactory, $performer ); |
| 31 | } |
| 32 | } |