Beispiel #1
0
 /**
  * @param array $headers
  * @param bool $hasMoreActivities
  * @return array
  */
 protected function generateHeaders(array $headers, $hasMoreActivities)
 {
     if ($hasMoreActivities && isset($headers['X-Activity-Last-Given'])) {
         // Set the "Link" header for the next page
         $nextPageParameters = ['since' => $headers['X-Activity-Last-Given'], 'limit' => $this->limit, 'sort' => $this->sort];
         if ($this->objectType && $this->objectId) {
             $nextPageParameters['object_type'] = $this->objectType;
             $nextPageParameters['object_id'] = $this->objectId;
         }
         if ($this->request->getParam('format') !== null) {
             $nextPageParameters['format'] = $this->request->getParam('format');
         }
         $nextPage = $this->request->getServerProtocol();
         # http
         $nextPage .= '://' . $this->request->getServerHost();
         # localhost
         $nextPage .= $this->request->getScriptName();
         # /ocs/v2.php
         $nextPage .= $this->request->getPathInfo();
         # /apps/activity/api/v2/activity
         $nextPage .= '?' . http_build_query($nextPageParameters);
         $headers['Link'] = '<' . $nextPage . '>; rel="next"';
     }
     return $headers;
 }