/**
  * /activities/{userId}/{groupId}/{optionalActvityId}
  *
  * examples:
  * /activities/john.doe/@self/1
  * /activities/john.doe/@self
  * /activities/john.doe/@friends
  */
 public function handleGet(RestRequestItem $requestItem)
 {
     $requestItem->parseUrlWithTemplate(self::$ACTIVITY_ID_PATH);
     $parameters = $requestItem->getParameters();
     $optionalActivityId = in_array('activityId', $parameters) ? $parameters['activityId'] : null;
     // TODO: Filter by fields
     // TODO: do we need to add pagination and sorting support?
     if ($optionalActivityId != null) {
         return $this->service->getActivity($requestItem->getUser(), $requestItem->getGroup(), $optionalActivityId, $requestItem->getStartIndex(), $requestItem->getCount(), $requestItem->getToken());
     }
     return $this->service->getActivities($requestItem->getUser(), $requestItem->getGroup(), $requestItem->getStartIndex(), $requestItem->getCount(), $requestItem->getToken());
 }
 /**
  * /people/{userId}/{groupId}/{optionalPersonId}
  *
  * examples:
  * /people/john.doe/@all
  * /people/john.doe/@friends
  * /people/john.doe/@self
  */
 public function handleGet(RestRequestItem $requestItem)
 {
     $requestItem->parseUrlWithTemplate(self::$PEOPLE_PATH);
     $parameters = $requestItem->getParameters();
     $optionalPersonId = in_array('personId', $parameters) ? $parameters['personId'] : null;
     $fields = $requestItem->getFieldsWithDefaultValue(self::$DEFAULT_PERSON_FIELDS);
     if ($optionalPersonId || is_object($requestItem->getGroup()) && $requestItem->getGroup()->getType() == 'self') {
         //FIXME same logic as the java code here, but doesn't seem to do much with the optionalPersonId which seems odd
         return $this->service->getPerson($requestItem->getUser(), $requestItem->getGroup(), $fields, $requestItem->getToken());
     }
     return $this->service->getPeople($requestItem->getUser(), $requestItem->getGroup(), $requestItem->getOrderBy(), $requestItem->getFilterBy(), $requestItem->getStartIndex(), $requestItem->getCount(), $fields, $requestItem->getNetworkDistance(), $requestItem->getToken());
 }
 /**
  *
  * @param ResponseItem $responseItem
  * @param RestRequestItem $requestItem
  */
 function outputResponse(ResponseItem $responseItem, RestRequestItem $requestItem)
 {
     $response = $responseItem->getResponse();
     if ($response instanceof RestfulCollection) {
         $itemsPerPage = $requestItem->getCount();
         if ($itemsPerPage > 0) {
             $response->itemsPerPage = $itemsPerPage;
         }
     }
     // several service calls return a null value
     if (!is_null($response)) {
         $this->encodeAndSendResponse($response);
     }
 }
Ejemplo n.º 4
0
 function outputResponse(ResponseItem $responseItem, RestRequestItem $requestItem)
 {
     $response = $responseItem->getResponse();
     if ($response instanceof RestfulCollection) {
         $itemsPerPage = $requestItem->getCount();
         if ($itemsPerPage > 0) {
             $response->itemsPerPage = $itemsPerPage;
         }
     }
     // several service calls return a null value
     if (!is_null($response)) {
         if (Config::get('debug')) {
             echo self::json_format(json_encode($response));
             // TODO: add a query option to pretty-print json output
         } else {
             echo json_encode($response);
         }
     }
 }
 /**
  * Tests RestRequestItem->getCount()
  */
 public function testGetCount()
 {
     $this->assertEquals('40', $this->RestRequestItem->getCount());
 }