Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
CrudContext | |
0.00% |
0 / 12 |
|
0.00% |
0 / 4 |
56 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
getDbLoadBalancer | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
getMediawikiUser | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
getRevisionStore | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace MediaWiki\WikispeechSpeechDataCollector\Crud; |
4 | |
5 | /** |
6 | * @file |
7 | * @ingroup Extensions |
8 | * @license GPL-2.0-or-later |
9 | */ |
10 | |
11 | use MediaWiki\Revision\RevisionStore; |
12 | use MWException; |
13 | use User as MwUser; |
14 | use Wikimedia\Rdbms\ILoadBalancer; |
15 | |
16 | /** |
17 | * Information required to access underlying data stores used by the various CRUD implementations. |
18 | * |
19 | * @since 0.1.0 |
20 | */ |
21 | class CrudContext { |
22 | |
23 | /** |
24 | * @see AbstractRdbmsCrud |
25 | * @var ILoadBalancer|null |
26 | */ |
27 | private $dbLoadBalancer; |
28 | |
29 | // @todo When bumping MW core version from 1.35, add TitleFactory and WikiPageFactory here, |
30 | // @todo and replace the use of static methods in {@link AbstractMcrCrud}. |
31 | |
32 | /** |
33 | * @see AbstractMcrCrud |
34 | * @var MwUser|null |
35 | */ |
36 | private $mediawikiUser; |
37 | |
38 | /** |
39 | * @see AbstractMcrCrud |
40 | * @var RevisionStore|null |
41 | */ |
42 | private $revisionStore; |
43 | |
44 | /** |
45 | * @param ILoadBalancer|null $dbLoadBalancer |
46 | * @param MwUser|null $mediawikiUser |
47 | * @param RevisionStore|null $revisionStore |
48 | * @since 0.1.0 |
49 | */ |
50 | public function __construct( |
51 | ?ILoadBalancer $dbLoadBalancer, |
52 | ?MwUser $mediawikiUser, |
53 | ?RevisionStore $revisionStore |
54 | ) { |
55 | $this->dbLoadBalancer = $dbLoadBalancer; |
56 | $this->mediawikiUser = $mediawikiUser; |
57 | $this->revisionStore = $revisionStore; |
58 | } |
59 | |
60 | /** |
61 | * @return ILoadBalancer |
62 | * @throws MWException If db load balancer not available in context. |
63 | * @since 0.1.0 |
64 | */ |
65 | public function getDbLoadBalancer(): ILoadBalancer { |
66 | if ( $this->dbLoadBalancer === null ) { |
67 | throw new MWException( 'Db load balancer not available in context!' ); |
68 | } |
69 | return $this->dbLoadBalancer; |
70 | } |
71 | |
72 | /** |
73 | * @return MwUser |
74 | * @throws MWException If user not available in context. |
75 | * @since 0.1.0 |
76 | */ |
77 | public function getMediawikiUser(): MwUser { |
78 | if ( $this->mediawikiUser === null ) { |
79 | throw new MWException( 'User not available in context!' ); |
80 | } |
81 | return $this->mediawikiUser; |
82 | } |
83 | |
84 | /** |
85 | * @return RevisionStore |
86 | * @throws MWException If revision store not available in context. |
87 | * @since 0.1.0 |
88 | */ |
89 | public function getRevisionStore(): RevisionStore { |
90 | if ( $this->revisionStore === null ) { |
91 | throw new MWException( 'Revision store not available in context!' ); |
92 | } |
93 | return $this->revisionStore; |
94 | } |
95 | |
96 | } |