Debian Codegraph @

includes/cache/LinkBatchFactory.php

raw symbols SCIP
1 <?php
2 /**
3 * Factory to create LinkBatch objects for querying page existence.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 * @file
21 * @ingroup Cache
22 */
23
24 namespace MediaWiki\Cache;
25
26 use MediaWiki\Language\Language;
27 use MediaWiki\Linker\LinksMigration;
28 use MediaWiki\Linker\LinkTarget;
29 use MediaWiki\Page\PageReference;
30 use MediaWiki\Title\TitleFormatter;
31 use Psr\Log\LoggerInterface;
32 use Wikimedia\Rdbms\IConnectionProvider;
33
34 /**
35 * @ingroup Cache
36 * @since 1.35
37 */
38 class LinkBatchFactory {
39
40 /**
41 * @var LinkCache
42 */
43 private $linkCache;
44
45 /**
46 * @var TitleFormatter
47 */
48 private $titleFormatter;
49
50 /**
51 * @var Language
52 */
53 private $contentLanguage;
54
55 /**
56 * @var GenderCache
57 */
58 private $genderCache;
59
60 /**
61 * @var IConnectionProvider
62 */
63 private $dbProvider;
64
65 /** @var LinksMigration */
66 private $linksMigration;
67
68 /** @var LoggerInterface */
69 private $logger;
70
71 public function __construct(
72 LinkCache $linkCache,
73 TitleFormatter $titleFormatter,
74 Language $contentLanguage,
75 GenderCache $genderCache,
76 IConnectionProvider $dbProvider,
77 LinksMigration $linksMigration,
78 LoggerInterface $logger
79 ) {
80 $this->linkCache = $linkCache;
81 $this->titleFormatter = $titleFormatter;
82 $this->contentLanguage = $contentLanguage;
83 $this->genderCache = $genderCache;
84 $this->dbProvider = $dbProvider;
85 $this->linksMigration = $linksMigration;
86 $this->logger = $logger;
87 }
88
89 /**
90 * @param iterable<LinkTarget>|iterable<PageReference> $initialItems items to be added
91 *
92 * @return LinkBatch
93 */
94 public function newLinkBatch( iterable $initialItems = [] ): LinkBatch {
95 return new LinkBatch(
96 $initialItems,
97 $this->linkCache,
98 $this->titleFormatter,
99 $this->contentLanguage,
100 $this->genderCache,
101 $this->dbProvider,
102 $this->linksMigration,
103 $this->logger
104 );
105 }
106 }