config = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig( 'textextracts' ); $this->cache = MediaWikiServices::getInstance()->getMainWANObjectCache(); } /** * @throws \ApiUsageException */ public function execute() { $user = $this->getUser(); if (!$user->isRegistered()) { $this->dieWithError('apierror-mustbeloggedin-generic', 'login-required'); return false; } $pointConfig = $this->config->get('IsekaiUserPointConfig'); $pointTypes = array_keys($pointConfig); /** @var IsekaiUserPointsFactory */ $userPointsFactory = MediaWikiServices::getInstance()->getService('IsekaiUserPoints'); /** @var array */ $userPoints = []; foreach ($pointTypes as $pointType) { $userPoint = $userPointsFactory->newFromUser($user, $pointType); if ($userPoint) { $userPoints[$pointType] = $userPointsFactory->newFromUser($user, $pointType); } } if (count($userPoints) === 0) { $this->dieWithError('apierror-isekaiuserpoints-notfound', 'not-found'); return false; } $result = $this->getResult(); foreach ($userPoints as $pointType => $userPoint) { $pointName = Utils::getPointName($pointType); $pointIcon = Utils::getPointIcon($pointType); $result->addValue(['query', $this->getModuleName()], $pointType, [ 'points' => $userPoint->points, 'timed_points_data' => $userPoint->timedPointsData, 'locked_points' => $userPoint->lockedPoints, 'locked_points_data' => $userPoint->lockedPointsData, 'name' => $pointName, 'icon' => $pointIcon, ]); } if (empty($userPoints)) { $result->addValue(['query'], $this->getModuleName(), new stdClass()); } } /** * @param array $params Ignored parameters * @return string */ public function getCacheMode($params) { return 'private'; } public function getAllowedParams() { return []; } }