/** * If $apiKey is not null, it has the priority over getting the api secret * from the token * * @param string $token - must be a valid token * @param string $apiKey (=null) * @return null|PcApiApp - null is the API key does not exist */ private function getApiApp($token, $apiKey = null) { if (null !== $apiKey) { $apiAppEntry = PcApiAppPeer::retrieveByApiKey($apiKey); if (null === $apiAppEntry) { return null; } return $apiAppEntry; } $c = new Criteria(); $c->addJoin(PcApiAppPeer::ID, PcApiTokenPeer::API_APP_ID); $c->add(PcApiTokenPeer::TOKEN, $token); $apiAppEntry = PcApiAppPeer::doSelectOne($c); if (!is_object($apiAppEntry)) { return null; } return $apiAppEntry; }