Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
93.33% |
14 / 15 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| WikiImporterFactory | |
100.00% |
14 / 14 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getWikiImporter | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | * @author Zabe |
| 6 | */ |
| 7 | |
| 8 | namespace MediaWiki\Import; |
| 9 | |
| 10 | use MediaWiki\Config\Config; |
| 11 | use MediaWiki\Content\IContentHandlerFactory; |
| 12 | use MediaWiki\HookContainer\HookContainer; |
| 13 | use MediaWiki\Language\Language; |
| 14 | use MediaWiki\Page\WikiPageFactory; |
| 15 | use MediaWiki\Permissions\Authority; |
| 16 | use MediaWiki\Revision\SlotRoleRegistry; |
| 17 | use MediaWiki\Title\NamespaceInfo; |
| 18 | use MediaWiki\Title\TitleFactory; |
| 19 | |
| 20 | /** |
| 21 | * Factory service for WikiImporter instances. |
| 22 | * |
| 23 | * @since 1.37 |
| 24 | */ |
| 25 | class WikiImporterFactory { |
| 26 | public function __construct( |
| 27 | private readonly Config $config, |
| 28 | private readonly HookContainer $hookContainer, |
| 29 | private readonly Language $contentLanguage, |
| 30 | private readonly NamespaceInfo $namespaceInfo, |
| 31 | private readonly TitleFactory $titleFactory, |
| 32 | private readonly WikiPageFactory $wikiPageFactory, |
| 33 | private readonly UploadRevisionImporter $uploadRevisionImporter, |
| 34 | private readonly IContentHandlerFactory $contentHandlerFactory, |
| 35 | private readonly SlotRoleRegistry $slotRoleRegistry, |
| 36 | ) { |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * @param ImportSource $source |
| 41 | * @param Authority $performer Authority used for permission checks only (to ensure that |
| 42 | * the user performing the import is allowed to edit the pages they're importing). To skip |
| 43 | * the checks, use UltimateAuthority. |
| 44 | * If you want to also log the import actions, see ImportReporter. |
| 45 | * @return WikiImporter |
| 46 | */ |
| 47 | public function getWikiImporter( ImportSource $source, Authority $performer ): WikiImporter { |
| 48 | return new WikiImporter( |
| 49 | $source, |
| 50 | $performer, |
| 51 | $this->config, |
| 52 | $this->hookContainer, |
| 53 | $this->contentLanguage, |
| 54 | $this->namespaceInfo, |
| 55 | $this->titleFactory, |
| 56 | $this->wikiPageFactory, |
| 57 | $this->uploadRevisionImporter, |
| 58 | $this->contentHandlerFactory, |
| 59 | $this->slotRoleRegistry |
| 60 | ); |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | /** @deprecated class alias since 1.46 */ |
| 65 | class_alias( WikiImporterFactory::class, 'WikiImporterFactory' ); |