public function getPersonData(UserId $userId, GroupId $groupId, $fields, $appId, SecurityToken $token)
 {
     $allData = XmlStateFileFetcher::get()->getAppData();
     $data = array();
     $ids = array();
     switch ($groupId->getType()) {
         case 'self':
             $ids[] = $userId->getUserId($token);
             break;
         case 'all':
         case 'friends':
             $friendIds = XmlStateFileFetcher::get()->getFriendIds();
             if (is_array($friendIds) && count($friendIds) && isset($friendIds[$userId->getUserId($token)])) {
                 $ids = $friendIds[$userId->getUserId($token)];
             }
             break;
         default:
             return new ResponseItem(NOT_IMPLEMENTED, "We don't support fetching data in batches yet", null);
             break;
     }
     foreach ($ids as $id) {
         if (isset($allData[$id])) {
             $allPersonData = $allData[$id];
             $personData = array();
             foreach (array_keys($allPersonData) as $key) {
                 if (in_array($key, $fields) || $fields[0] == "*") {
                     $personData[$key] = $allPersonData[$key];
                 }
             }
             $data[$id] = $personData;
         }
     }
     return new ResponseItem(null, null, RestFulCollection::createFromEntry($data));
 }
Ejemplo n.º 2
0
 public function getPersonData(UserId $userId, GroupId $groupId, $fields, $appId, SecurityToken $token)
 {
     $ids = array();
     switch ($groupId->getType()) {
         case 'self':
             $ids[] = $userId->getUserId($token);
             break;
         case 'all':
         case 'friends':
             $friendIds = espritDBFetcher::get()->getFriendIds($userId->getUserId($token));
             if (is_array($friendIds) && count($friendIds)) {
                 $ids = $friendIds;
             }
             break;
         default:
             return new ResponseItem(NOT_IMPLEMENTED, "We don't support fetching data in batches yet", null);
             break;
     }
     $data = espritDBFetcher::get()->getAppData($ids, $fields, $appId);
     return new ResponseItem(null, null, RestFulCollection::createFromEntry($data));
 }
 /**
  * Tests RestFulCollection->createFromEntry()
  */
 public function testCreateFromEntry()
 {
     $entry = array('Entry');
     $restFulCollection = RestFulCollection::createFromEntry($entry);
     $this->assertEquals(1, $restFulCollection->getTotalResults());
     $this->assertEquals($entry, $restFulCollection->getEntry());
     $this->assertEquals(0, $restFulCollection->getStartIndex());
 }