public function getAccessToken($rid) { $token = $this->tokens->getAccessTokenByRID($rid); if ($token != null) { return $token; } $token = new TPAccessToken(new TPRID($rid)); $token->getTokenData()->addField(TPTokenData::EX, -1); if ($token->getAccessState() == null) { if ($tokens->size() == 0) { $token->setAccessState(TPAccessState::NO_TOKENS_FOUND); } else { $token->setAccessState(AccessState::RID_NOT_FOUND); } } return $token; }