예제 #1
0
 /**
  * Returns a response array containing an 'events' and 'pagination' element.
  * Each event in this response is also stored in the cache so that a relation
  * can be made between the API URLs and Event entities.
  *
  * @param string $url API Url to query for one or more events. Either a
  *                    listing can be retrieved or a single event.
  * @param array  $queryParams
  *
  * @return array
  */
 public function getCollection($uri, array $queryParams = array())
 {
     $events = (array) json_decode($this->apiGet($uri, $queryParams));
     $meta = array_pop($events);
     $collectionData = array();
     foreach ($events['events'] as $item) {
         $event = new EventEntity($item);
         $collectionData['events'][] = $event;
         // save the URL so we can look up by it
         $this->eventDb->save($event);
     }
     $collectionData['pagination'] = $meta;
     return $collectionData;
 }
예제 #2
0
 /**
  * Returns a response array containing an 'events' and 'pagination' element.
  * Each event in this response is also stored in the cache so that a relation
  * can be made between the API URLs and Event entities.
  *
  * @param string $url API Url to query for one or more events. Either a
  *                    listing can be retrieved or a single event.
  * @param array  $queryParams
  *
  * @return array
  */
 public function getCollection($uri, array $queryParams = array())
 {
     $events = (array) json_decode($this->apiGet($uri, $queryParams));
     $meta = array_pop($events);
     $collectionData = array();
     foreach ($events['events'] as $item) {
         $event = new EventEntity($item);
         foreach ($event->getHosts() as $hostsInfo) {
             if (isset($hostsInfo->host_uri)) {
                 $hostsInfo->username = $this->userApi->getUsername($hostsInfo->host_uri);
             }
         }
         $collectionData['events'][] = $event;
         // save the URL so we can look up by it
         $this->eventDb->save($event);
     }
     $collectionData['pagination'] = $meta;
     return $collectionData;
 }