Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 16 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| ApiCentralNoticeQueryActiveCampaigns | |
0.00% |
0 / 16 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| execute | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| getAllowedParams | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
2 | |||
| getExamplesMessages | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | use MediaWiki\Api\ApiQuery; |
| 4 | use MediaWiki\Api\ApiQueryBase; |
| 5 | use Wikimedia\ParamValidator\ParamValidator; |
| 6 | |
| 7 | /** |
| 8 | * Query of currently active CentralNotice campaigns. |
| 9 | */ |
| 10 | class ApiCentralNoticeQueryActiveCampaigns extends ApiQueryBase { |
| 11 | |
| 12 | public function __construct( ApiQuery $query, string $moduleName ) { |
| 13 | // Though there are no parameters, we set a prefix for them, just in case we |
| 14 | // add parameters later. |
| 15 | parent::__construct( $query, $moduleName, 'cnac' ); |
| 16 | } |
| 17 | |
| 18 | public function execute() { |
| 19 | $params = $this->extractRequestParams(); |
| 20 | |
| 21 | $this->getResult()->addValue( |
| 22 | [ 'query', $this->getModuleName() ], |
| 23 | 'campaigns', |
| 24 | Campaign::getActiveCampaignsAndBanners( $params[ 'includefuture' ] ) |
| 25 | ); |
| 26 | } |
| 27 | |
| 28 | /** @inheritDoc */ |
| 29 | public function getAllowedParams() { |
| 30 | return [ |
| 31 | 'includefuture' => [ |
| 32 | ParamValidator::PARAM_TYPE => 'boolean', |
| 33 | ] |
| 34 | ]; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * @inheritDoc |
| 39 | */ |
| 40 | protected function getExamplesMessages() { |
| 41 | return [ |
| 42 | 'action=query&list=centralnoticeactivecampaigns&format=json' |
| 43 | => 'apihelp-query+centralnoticeactivecampaigns-example-1', |
| 44 | ]; |
| 45 | } |
| 46 | } |