/** * @param string $result * * @return bool */ public function doUpdate($result) { $xml = $this->createXmlObject($result); /** @var ApiKeyInfo $apiKeyInfo */ $apiKeyInfo = ApiKeyInfo::findOne(['id' => $this->apiID]); if (!$apiKeyInfo) { $apiKeyInfo = new ApiKeyInfo(); $apiKeyInfo->apiID = $this->apiID; } $dataKey = self::getXmlAttr($xml->result->key); $apiKeyInfo->timeUpdated = time(); $apiKeyInfo->accessMask = $dataKey['accessMask']; $apiKeyInfo->type = $dataKey['type']; $apiKeyInfo->expires = $dataKey['expires'] ? strtotime($dataKey['expires']) : null; return $apiKeyInfo->save(); }
/** * @return \yii\db\ActiveQuery */ public function getInfo() { return $this->hasOne(ApiKeyInfo::className(), ['apiID' => 'id']); }