Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
CommunityStructuredMentorWriter | |
0.00% |
0 / 13 |
|
0.00% |
0 / 3 |
30 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
doSaveMentorData | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
isBlocked | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace GrowthExperiments\Mentorship\Provider; |
4 | |
5 | use MediaWiki\Extension\CommunityConfiguration\Provider\IConfigurationProvider; |
6 | use MediaWiki\Extension\CommunityConfiguration\Store\WikiPageStore; |
7 | use MediaWiki\Status\StatusFormatter; |
8 | use MediaWiki\User\UserFactory; |
9 | use MediaWiki\User\UserIdentity; |
10 | use MediaWiki\User\UserIdentityLookup; |
11 | use StatusValue; |
12 | use Wikimedia\Rdbms\IDBAccessObject; |
13 | |
14 | class CommunityStructuredMentorWriter extends AbstractStructuredMentorWriter { |
15 | use CommunityGetMentorDataTrait; |
16 | |
17 | public function __construct( |
18 | MentorProvider $mentorProvider, |
19 | UserIdentityLookup $userIdentityLookup, |
20 | UserFactory $userFactory, |
21 | StatusFormatter $statusFormatter, |
22 | IConfigurationProvider $provider |
23 | ) { |
24 | parent::__construct( $mentorProvider, $userIdentityLookup, $userFactory ); |
25 | |
26 | $this->statusFormatter = $statusFormatter; |
27 | $this->provider = $provider; |
28 | } |
29 | |
30 | protected function doSaveMentorData( |
31 | array $mentorData, |
32 | string $summary, |
33 | UserIdentity $performer, |
34 | bool $bypassWarnings |
35 | ): StatusValue { |
36 | return $this->provider->alwaysStoreValidConfiguration( |
37 | [ self::CONFIG_KEY => $mentorData ], |
38 | $this->userFactory->newFromUserIdentity( $performer ), |
39 | $summary |
40 | ); |
41 | } |
42 | |
43 | /** |
44 | * @inheritDoc |
45 | */ |
46 | public function isBlocked( |
47 | UserIdentity $performer, int $freshness = IDBAccessObject::READ_NORMAL |
48 | ): bool { |
49 | $store = $this->provider->getStore(); |
50 | $block = $this->userFactory->newFromUserIdentity( $performer )->getBlock( $freshness ); |
51 | if ( $store instanceof WikiPageStore ) { |
52 | return $block && $block->appliesToTitle( $store->getConfigurationTitle() ); |
53 | } |
54 | return (bool)$block; |
55 | } |
56 | } |