Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 20 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
SignatureValidatorFactory | |
0.00% |
0 / 20 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 8 |
|
0.00% |
0 / 1 |
2 | |||
newSignatureValidator | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
2 |
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 Derick Alangi |
20 | */ |
21 | |
22 | namespace MediaWiki\Preferences; |
23 | |
24 | use ExtensionRegistry; |
25 | use MediaWiki\Config\ServiceOptions; |
26 | use MediaWiki\Parser\Parsoid\Config\PageConfigFactory; |
27 | use MediaWiki\SpecialPage\SpecialPageFactory; |
28 | use MediaWiki\Title\TitleFactory; |
29 | use MediaWiki\User\UserIdentity; |
30 | use MessageLocalizer; |
31 | use ParserOptions; |
32 | |
33 | /** |
34 | * @since 1.38 |
35 | */ |
36 | class SignatureValidatorFactory { |
37 | /** @var ServiceOptions */ |
38 | private $serviceOptions; |
39 | |
40 | /** @var callable */ |
41 | private $parserFactoryClosure; |
42 | |
43 | /** @var callable */ |
44 | private $parsoidClosure; |
45 | |
46 | private PageConfigFactory $pageConfigFactory; |
47 | |
48 | /** @var SpecialPageFactory */ |
49 | private $specialPageFactory; |
50 | |
51 | /** @var TitleFactory */ |
52 | private $titleFactory; |
53 | |
54 | private ExtensionRegistry $extensionRegistry; |
55 | |
56 | /** |
57 | * @param ServiceOptions $options |
58 | * @param callable $parserFactoryClosure A function which returns a ParserFactory. |
59 | * We use this instead of an actual ParserFactory to avoid a circular dependency, |
60 | * since Parser also needs a SignatureValidatorFactory for signature formatting. |
61 | * @param callable $parsoidClosure A function which returns a Parsoid, same as above. |
62 | * @param PageConfigFactory $pageConfigFactory |
63 | * @param SpecialPageFactory $specialPageFactory |
64 | * @param TitleFactory $titleFactory |
65 | * @param ExtensionRegistry $extensionRegistry |
66 | */ |
67 | public function __construct( |
68 | ServiceOptions $options, |
69 | callable $parserFactoryClosure, |
70 | callable $parsoidClosure, |
71 | PageConfigFactory $pageConfigFactory, |
72 | SpecialPageFactory $specialPageFactory, |
73 | TitleFactory $titleFactory, |
74 | ExtensionRegistry $extensionRegistry |
75 | ) { |
76 | // Configuration |
77 | $this->serviceOptions = $options; |
78 | $this->serviceOptions->assertRequiredOptions( SignatureValidator::CONSTRUCTOR_OPTIONS ); |
79 | $this->parserFactoryClosure = $parserFactoryClosure; |
80 | $this->parsoidClosure = $parsoidClosure; |
81 | $this->pageConfigFactory = $pageConfigFactory; |
82 | $this->specialPageFactory = $specialPageFactory; |
83 | $this->titleFactory = $titleFactory; |
84 | $this->extensionRegistry = $extensionRegistry; |
85 | } |
86 | |
87 | /** |
88 | * @param UserIdentity $user |
89 | * @param MessageLocalizer|null $localizer |
90 | * @param ParserOptions $popts |
91 | * @return SignatureValidator |
92 | */ |
93 | public function newSignatureValidator( |
94 | UserIdentity $user, |
95 | ?MessageLocalizer $localizer, |
96 | ParserOptions $popts |
97 | ): SignatureValidator { |
98 | return new SignatureValidator( |
99 | $this->serviceOptions, |
100 | $user, |
101 | $localizer, |
102 | $popts, |
103 | ( $this->parserFactoryClosure )(), |
104 | ( $this->parsoidClosure )(), |
105 | $this->pageConfigFactory, |
106 | $this->specialPageFactory, |
107 | $this->titleFactory, |
108 | $this->extensionRegistry |
109 | ); |
110 | } |
111 | } |