contributionsLookup = $contributionsLookup; $this->userNameUtils = $userNameUtils; } protected function postInitSetup() { $this->me = $this->getConfig()['mode'] === 'me'; } /** * Returns the user who's contributions we are requesting. * Either me (requesting user) or another user. * * @return UserIdentity * @throws LocalizedHttpException */ protected function getTargetUser() { if ( $this->me ) { $user = $this->getAuthority()->getUser(); if ( !$user->isRegistered() ) { throw new LocalizedHttpException( new MessageValue( 'rest-permission-denied-anon' ), 401 ); } return $user; } /** @var UserIdentity $user */ $user = $this->getValidatedParams()['user']; $name = $user->getName(); if ( !$this->userNameUtils->isIp( $name ) && !$user->isRegistered() ) { throw new LocalizedHttpException( new MessageValue( 'rest-nonexistent-user', [ $name ] ), 404 ); } return $user; } }