Merge "docs: Fix typo"
[mediawiki.git] / includes / cache / LinkBatchFactory.php
blob78f46bcfa9941529aebbd14c39509f6bf71d534c
1 <?php
2 /**
3 * Factory to create LinkBatch objects for querying page existence.
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.
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.
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
20 * @file
21 * @ingroup Cache
24 namespace MediaWiki\Cache;
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;
34 /**
35 * @ingroup Cache
36 * @since 1.35
38 class LinkBatchFactory {
40 /**
41 * @var LinkCache
43 private $linkCache;
45 /**
46 * @var TitleFormatter
48 private $titleFormatter;
50 /**
51 * @var Language
53 private $contentLanguage;
55 /**
56 * @var GenderCache
58 private $genderCache;
60 /**
61 * @var IConnectionProvider
63 private $dbProvider;
65 /** @var LinksMigration */
66 private $linksMigration;
68 /** @var LoggerInterface */
69 private $logger;
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;
89 /**
90 * @param iterable<LinkTarget>|iterable<PageReference> $initialItems items to be added
92 * @return LinkBatch
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