Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
ApiQueryStarredMentees | |
0.00% |
0 / 14 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
execute | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
12 |
1 | <?php |
2 | |
3 | namespace GrowthExperiments\Api; |
4 | |
5 | use GrowthExperiments\MentorDashboard\MenteeOverview\StarredMenteesStore; |
6 | use MediaWiki\Api\ApiQuery; |
7 | use MediaWiki\Api\ApiQueryBase; |
8 | |
9 | class ApiQueryStarredMentees extends ApiQueryBase { |
10 | private StarredMenteesStore $starredMenteesStore; |
11 | |
12 | public function __construct( |
13 | ApiQuery $mainModule, |
14 | string $moduleName, |
15 | StarredMenteesStore $starredMenteesStore |
16 | ) { |
17 | parent::__construct( $mainModule, $moduleName ); |
18 | |
19 | $this->starredMenteesStore = $starredMenteesStore; |
20 | } |
21 | |
22 | /** |
23 | * @inheritDoc |
24 | */ |
25 | public function execute() { |
26 | if ( !$this->getUser()->isNamed() ) { |
27 | $this->dieWithError( [ 'apierror-permissiondenied-generic' ] ); |
28 | } |
29 | |
30 | $res = []; |
31 | $starredMentees = $this->starredMenteesStore->getStarredMentees( $this->getUser() ); |
32 | foreach ( $starredMentees as $user ) { |
33 | $res[] = [ |
34 | 'id' => $user->getId(), |
35 | 'username' => $user->getName() |
36 | ]; |
37 | } |
38 | $this->getResult()->addValue( null, $this->getModuleName(), [ |
39 | 'mentees' => $res |
40 | ] ); |
41 | } |
42 | } |