Debian Codegraph @

includes/import/WikiImporterFactory.php

raw symbols SCIP
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
17 *
18 * @file
19 * @author Zabe
20 */
21
22 use MediaWiki\Config\Config;
23 use MediaWiki\Content\IContentHandlerFactory;
24 use MediaWiki\Context\RequestContext;
25 use MediaWiki\HookContainer\HookContainer;
26 use MediaWiki\Language\Language;
27 use MediaWiki\Page\WikiPageFactory;
28 use MediaWiki\Permissions\Authority;
29 use MediaWiki\Revision\SlotRoleRegistry;
30 use MediaWiki\Title\NamespaceInfo;
31 use MediaWiki\Title\TitleFactory;
32
33 /**
34 * Factory service for WikiImporter instances.
35 *
36 * @since 1.37
37 */
38 class WikiImporterFactory {
39 private Config $config;
40 private HookContainer $hookContainer;
41 private Language $contentLanguage;
42 private NamespaceInfo $namespaceInfo;
43 private TitleFactory $titleFactory;
44 private WikiPageFactory $wikiPageFactory;
45 private UploadRevisionImporter $uploadRevisionImporter;
46 private IContentHandlerFactory $contentHandlerFactory;
47 private SlotRoleRegistry $slotRoleRegistry;
48
49 public function __construct(
50 Config $config,
51 HookContainer $hookContainer,
52 Language $contentLanguage,
53 NamespaceInfo $namespaceInfo,
54 TitleFactory $titleFactory,
55 WikiPageFactory $wikiPageFactory,
56 UploadRevisionImporter $uploadRevisionImporter,
57 IContentHandlerFactory $contentHandlerFactory,
58 SlotRoleRegistry $slotRoleRegistry
59 ) {
60 $this->config = $config;
61 $this->hookContainer = $hookContainer;
62 $this->contentLanguage = $contentLanguage;
63 $this->namespaceInfo = $namespaceInfo;
64 $this->titleFactory = $titleFactory;
65 $this->wikiPageFactory = $wikiPageFactory;
66 $this->uploadRevisionImporter = $uploadRevisionImporter;
67 $this->contentHandlerFactory = $contentHandlerFactory;
68 $this->slotRoleRegistry = $slotRoleRegistry;
69 }
70
71 /**
72 * @param ImportSource $source
73 * @param Authority|null $performer Authority used for permission checks only (to ensure that
74 * the user performing the import is allowed to edit the pages they're importing). To skip
75 * the checks, use UltimateAuthority.
76 *
77 * When omitted, defaults to the current global user. This behavior is deprecated since 1.42.
78 *
79 * If you want to also log the import actions, see ImportReporter.
80 * @return WikiImporter
81 */
82 public function getWikiImporter( ImportSource $source, ?Authority $performer = null ): WikiImporter {
83 if ( !$performer ) {
84 wfDeprecated( __METHOD__ . ' without $performer', '1.42' );
85 $performer = RequestContext::getMain()->getAuthority();
86 }
87
88 return new WikiImporter(
89 $source,
90 $performer,
91 $this->config,
92 $this->hookContainer,
93 $this->contentLanguage,
94 $this->namespaceInfo,
95 $this->titleFactory,
96 $this->wikiPageFactory,
97 $this->uploadRevisionImporter,
98 $this->contentHandlerFactory,
99 $this->slotRoleRegistry
100 );
101 }
102 }