MediaWiki REL1_39
ContributionsCountHandler.php
Go to the documentation of this file.
1<?php
2
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',
32 ParamValidator::PARAM_REQUIRED => false,
33 ParamValidator::PARAM_DEFAULT => null,
34 ]
35 ];
36 if ( $this->me === false ) {
37 $settings['user'] = [
38 self::PARAM_SOURCE => 'path',
39 ParamValidator::PARAM_REQUIRED => true,
40 ParamValidator::PARAM_TYPE => 'user',
41 UserDef::PARAM_RETURN_OBJECT => true,
42 UserDef::PARAM_ALLOWED_USER_TYPES => [ 'name', 'ip' ],
43 ];
44 }
45 return $settings;
46 }
47
48}
Type definition for user types.
Definition UserDef.php:27
getTargetUser()
Returns the user who's contributions we are requesting.
getParamSettings()
Fetch ParamValidator settings for parameters.
getValidatedParams()
Fetch the validated parameters.
Definition Handler.php:336
getAuthority()
Get the current acting authority.
Definition Handler.php:157
Service for formatting and validating API parameters.
An interface similar to PSR-7's ResponseInterface, the primary difference being that it is mutable.
Copyright (C) 2011-2020 Wikimedia Foundation and others.