services = $services; $this->config = $services->getMainConfig(); $this->pointConfig = $this->config->get('IsekaiUserPointConfig'); $this->dailySignConfig = $this->config->get('IsekaiUserDailySignConfig'); } /** * @param User $user * @return IsekaiUserDailySign|null */ public function newFromUser(User $user) { if (!$this->dailySignConfig) { throw new \Exception('$wgIsekaiUserDailySignConfig is not configured'); } if (!$user->isRegistered()) { return null; } $userId = $user->getId(); $cacheKey = $userId; if (!isset(self::$instances[$cacheKey])) { self::$instances[$cacheKey] = new IsekaiUserDailySign($user, $this->pointConfig, $this->dailySignConfig, $this->services); } return self::$instances[$cacheKey]; } /** * @param int $userId * @return IsekaiUserDailySign|null */ public function newFromUserId($userId) { $user = $this->services->getUserFactory()->newFromId($userId); if (!$user) { return null; } return $this->newFromUser($user); } }