Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
66.67% |
6 / 9 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
ApiQueryMentorStatus | |
66.67% |
6 / 9 |
|
50.00% |
1 / 2 |
4.59 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
3 |
1 | <?php |
2 | |
3 | namespace GrowthExperiments\Api; |
4 | |
5 | use GrowthExperiments\MentorDashboard\MentorTools\MentorStatusManager; |
6 | use GrowthExperiments\Mentorship\Provider\MentorProvider; |
7 | use MediaWiki\Api\ApiQuery; |
8 | use MediaWiki\Api\ApiQueryBase; |
9 | |
10 | class ApiQueryMentorStatus extends ApiQueryBase { |
11 | |
12 | private MentorProvider $mentorProvider; |
13 | private MentorStatusManager $mentorStatusManager; |
14 | |
15 | public function __construct( |
16 | ApiQuery $mainModule, |
17 | string $moduleName, |
18 | MentorProvider $mentorProvider, |
19 | MentorStatusManager $mentorStatusManager |
20 | ) { |
21 | parent::__construct( $mainModule, $moduleName ); |
22 | |
23 | $this->mentorProvider = $mentorProvider; |
24 | $this->mentorStatusManager = $mentorStatusManager; |
25 | } |
26 | |
27 | /** |
28 | * @inheritDoc |
29 | */ |
30 | public function execute() { |
31 | if ( |
32 | !$this->getConfig()->get( 'GEMentorDashboardEnabled' ) || |
33 | !$this->mentorProvider->isMentor( $this->getUser() ) |
34 | ) { |
35 | $this->dieWithError( [ 'apierror-permissiondenied-generic' ] ); |
36 | } |
37 | |
38 | $this->getResult()->addValue( null, $this->getModuleName(), [ |
39 | 'mentorstatus' => $this->mentorStatusManager->getMentorStatus( $this->getUser() ) |
40 | ] ); |
41 | } |
42 | } |