Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
19 / 19 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
LinkBatchFactory | |
100.00% |
19 / 19 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
1 | |||
newLinkBatch | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
1 |
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 MediaWiki\User\TempUser\TempUserDetailsLookup; |
32 | use Psr\Log\LoggerInterface; |
33 | use Wikimedia\Rdbms\IConnectionProvider; |
34 | |
35 | /** |
36 | * @ingroup Cache |
37 | * @since 1.35 |
38 | */ |
39 | class LinkBatchFactory { |
40 | |
41 | /** |
42 | * @var LinkCache |
43 | */ |
44 | private $linkCache; |
45 | |
46 | /** |
47 | * @var TitleFormatter |
48 | */ |
49 | private $titleFormatter; |
50 | |
51 | /** |
52 | * @var Language |
53 | */ |
54 | private $contentLanguage; |
55 | |
56 | /** |
57 | * @var GenderCache |
58 | */ |
59 | private $genderCache; |
60 | |
61 | /** |
62 | * @var IConnectionProvider |
63 | */ |
64 | private $dbProvider; |
65 | |
66 | /** @var LinksMigration */ |
67 | private $linksMigration; |
68 | |
69 | private TempUserDetailsLookup $tempUserDetailsLookup; |
70 | |
71 | /** @var LoggerInterface */ |
72 | private $logger; |
73 | |
74 | public function __construct( |
75 | LinkCache $linkCache, |
76 | TitleFormatter $titleFormatter, |
77 | Language $contentLanguage, |
78 | GenderCache $genderCache, |
79 | IConnectionProvider $dbProvider, |
80 | LinksMigration $linksMigration, |
81 | TempUserDetailsLookup $tempUserDetailsLookup, |
82 | LoggerInterface $logger |
83 | ) { |
84 | $this->linkCache = $linkCache; |
85 | $this->titleFormatter = $titleFormatter; |
86 | $this->contentLanguage = $contentLanguage; |
87 | $this->genderCache = $genderCache; |
88 | $this->dbProvider = $dbProvider; |
89 | $this->linksMigration = $linksMigration; |
90 | $this->tempUserDetailsLookup = $tempUserDetailsLookup; |
91 | $this->logger = $logger; |
92 | } |
93 | |
94 | /** |
95 | * @param iterable<LinkTarget>|iterable<PageReference> $initialItems items to be added |
96 | * |
97 | * @return LinkBatch |
98 | */ |
99 | public function newLinkBatch( iterable $initialItems = [] ): LinkBatch { |
100 | return new LinkBatch( |
101 | $initialItems, |
102 | $this->linkCache, |
103 | $this->titleFormatter, |
104 | $this->contentLanguage, |
105 | $this->genderCache, |
106 | $this->dbProvider, |
107 | $this->linksMigration, |
108 | $this->tempUserDetailsLookup, |
109 | $this->logger |
110 | ); |
111 | } |
112 | } |