MediaWiki REL1_35
ContributionsCountHandler.php
Go to the documentation of this file.
1<?php
2
4
12
17
22
24 $this->contributionsLookup = $contributionsLookup;
25 }
26
31 public function execute() {
32 $user = RequestContext::getMain()->getUser();
33 if ( $user->isAnon() ) {
34 throw new LocalizedHttpException(
35 new MessageValue( 'rest-permission-denied-anon' ), 401
36 );
37 }
38
39 $tag = $this->getValidatedParams()['tag'];
40 $count = $this->contributionsLookup->getContributionCount( $user, $user, $tag );
41
42 $response = [ 'count' => $count ];
43
44 return $response;
45 }
46
47 public function getParamSettings() {
48 return [
49 'tag' => [
50 self::PARAM_SOURCE => 'query',
51 ParamValidator::PARAM_TYPE => 'string',
52 ParamValidator::PARAM_REQUIRED => false,
53 ParamValidator::PARAM_DEFAULT => null,
54 ],
55 ];
56 }
57
58}
__construct(ContributionsLookup $contributionsLookup)
getParamSettings()
Fetch ParamValidator settings for parameters.
Base class for REST route handlers.
Definition Handler.php:16
getValidatedParams()
Fetch the validated parameters.
Definition Handler.php:257
Group all the pieces relevant to the context of a request into one instance @newable.
Value object representing a message for i18n.
Service for formatting and validating API parameters.
An interface similar to PSR-7's ResponseInterface, the primary difference being that it is mutable.