Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
BlockPermissionCheckerFactory | |
0.00% |
0 / 12 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
newBlockPermissionChecker | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
newChecker | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | /** |
4 | * This program is free software; you can redistribute it and/or modify |
5 | * it under the terms of the GNU General Public License as published by |
6 | * the Free Software Foundation; either version 2 of the License, or |
7 | * (at your option) any later version. |
8 | * |
9 | * This program is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 | * GNU General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU General Public License along |
15 | * with this program; if not, write to the Free Software Foundation, Inc., |
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | * http://www.gnu.org/copyleft/gpl.html |
18 | * |
19 | * @file |
20 | */ |
21 | |
22 | namespace MediaWiki\Block; |
23 | |
24 | use MediaWiki\Config\ServiceOptions; |
25 | use MediaWiki\Permissions\Authority; |
26 | use MediaWiki\User\UserIdentity; |
27 | |
28 | /** |
29 | * Factory class for BlockPermissionChecker |
30 | * |
31 | * @since 1.35 |
32 | */ |
33 | class BlockPermissionCheckerFactory { |
34 | /** |
35 | * @internal only to be used by ServiceWiring |
36 | */ |
37 | public const CONSTRUCTOR_OPTIONS = BlockPermissionChecker::CONSTRUCTOR_OPTIONS; |
38 | |
39 | private ServiceOptions $options; |
40 | private BlockTargetFactory $blockTargetFactory; |
41 | |
42 | public function __construct( |
43 | ServiceOptions $options, |
44 | BlockTargetFactory $blockTargetFactory |
45 | ) { |
46 | $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS ); |
47 | $this->options = $options; |
48 | $this->blockTargetFactory = $blockTargetFactory; |
49 | } |
50 | |
51 | /** |
52 | * @param UserIdentity|string|null $target Target of the validated block; may be null if unknown |
53 | * @param Authority $performer Performer of the validated block |
54 | * @return BlockPermissionChecker |
55 | * |
56 | * @deprecated since 1.44 use newChecker, which does not require $target |
57 | */ |
58 | public function newBlockPermissionChecker( |
59 | $target, |
60 | Authority $performer |
61 | ) { |
62 | $checker = $this->newChecker( $performer ); |
63 | if ( $target !== null ) { |
64 | $checker->setTarget( $target ); |
65 | } |
66 | return $checker; |
67 | } |
68 | |
69 | /** |
70 | * @param Authority $performer Performer of the block |
71 | * @return BlockPermissionChecker |
72 | */ |
73 | public function newChecker( Authority $performer ) { |
74 | return new BlockPermissionChecker( |
75 | $this->options, |
76 | $this->blockTargetFactory, |
77 | $performer |
78 | ); |
79 | } |
80 | } |