MediaWiki  master
ContributionsCountHandler.php
Go to the documentation of this file.
1 <?php
2 
3 namespace MediaWiki\Rest\Handler;
4 
9 
14 
19  public function execute() {
20  $target = $this->getTargetUser();
21  $tag = $this->getValidatedParams()['tag'];
22  $count = $this->contributionsLookup->getContributionCount( $target, $this->getAuthority(), $tag );
23  $response = [ 'count' => $count ];
24  return $response;
25  }
26 
27  public function getParamSettings() {
28  $settings = [
29  'tag' => [
30  self::PARAM_SOURCE => 'query',
31  ParamValidator::PARAM_TYPE => 'string',
34  ]
35  ];
36  if ( $this->me === false ) {
37  $settings['user'] = [
38  self::PARAM_SOURCE => 'path',
41  UserDef::PARAM_RETURN_OBJECT => true,
42  UserDef::PARAM_ALLOWED_USER_TYPES => [ 'name', 'ip' ],
43  ];
44  }
45  return $settings;
46  }
47 
48 }
getTargetUser()
Returns the user whose contributions we are requesting.
getParamSettings()
Fetch ParamValidator settings for parameters.
getValidatedParams()
Fetch the validated parameters.
Definition: Handler.php:371
getAuthority()
Get the current acting authority.
Definition: Handler.php:166
Service for formatting and validating API parameters.
const PARAM_DEFAULT
(mixed) Default value of the parameter.
const PARAM_TYPE
(string|array) Type of the parameter.
const PARAM_REQUIRED
(bool) Indicate that the parameter is required.
An interface similar to PSR-7's ResponseInterface, the primary difference being that it is mutable.
Copyright (C) 2011-2020 Wikimedia Foundation and others.