Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
|||
| 1 | <?php |
| 2 | namespace MediaWiki\Extension\VisualEditor; |
| 3 | |
| 4 | use MediaWiki\Page\PageIdentity; |
| 5 | use MediaWiki\Revision\RevisionRecord; |
| 6 | use Wikimedia\Bcp47Code\Bcp47Code; |
| 7 | |
| 8 | interface ParsoidClient { |
| 9 | |
| 10 | /** |
| 11 | * Request page HTML |
| 12 | * |
| 13 | * @param RevisionRecord $revision Page revision |
| 14 | * @param Bcp47Code|null $targetLanguage Desired output language |
| 15 | * |
| 16 | * @return array An array mimicking a RESTbase server's response, with keys: 'headers' and 'body' |
| 17 | * @phan-return array{body:string,headers:array<string,string>} |
| 18 | */ |
| 19 | public function getPageHtml( RevisionRecord $revision, ?Bcp47Code $targetLanguage ): array; |
| 20 | |
| 21 | /** |
| 22 | * Transform HTML to wikitext via Parsoid |
| 23 | * |
| 24 | * @param PageIdentity $page The page the content belongs to |
| 25 | * @param Bcp47Code $targetLanguage The desired output language |
| 26 | * @param string $html The HTML of the page to be transformed |
| 27 | * @param ?int $oldid What oldid revision, if any, to base the request from (default: `null`) |
| 28 | * @param ?string $etag The ETag to set in the HTTP request header |
| 29 | * |
| 30 | * @return array An array mimicking a RESTbase server's response, with keys: 'headers' and 'body' |
| 31 | * @phan-return array{body:string,headers:array<string,string>} |
| 32 | */ |
| 33 | public function transformHTML( |
| 34 | PageIdentity $page, |
| 35 | Bcp47Code $targetLanguage, |
| 36 | string $html, |
| 37 | ?int $oldid, |
| 38 | ?string $etag |
| 39 | ): array; |
| 40 | |
| 41 | /** |
| 42 | * Transform wikitext to HTML via Parsoid. |
| 43 | * |
| 44 | * @param PageIdentity $page The page the content belongs to |
| 45 | * @param Bcp47Code $targetLanguage The desired output language |
| 46 | * @param string $wikitext The wikitext fragment to parse |
| 47 | * @param bool $bodyOnly Whether to provide only the contents of the `<body>` tag |
| 48 | * @param ?int $oldid What oldid revision, if any, to base the request from (default: `null`) |
| 49 | * @param bool $stash Whether to stash the result in the server-side cache (default: `false`) |
| 50 | * |
| 51 | * @return array An array mimicking a RESTbase server's response, with keys: 'headers' and 'body' |
| 52 | * @phan-return array{body:string,headers:array<string,string>} |
| 53 | */ |
| 54 | public function transformWikitext( |
| 55 | PageIdentity $page, |
| 56 | Bcp47Code $targetLanguage, |
| 57 | string $wikitext, |
| 58 | bool $bodyOnly, |
| 59 | ?int $oldid, |
| 60 | bool $stash |
| 61 | ): array; |
| 62 | } |