コード例 #1
0
ファイル: QueryProcessor.php プロジェクト: lionsoft/phpodata
 /**
  * Process $skip and $top options
  * 
  * @return void
  * 
  * @throws ODataException Throws syntax error if the $skip or $top option
  *                        is specified with non-integer value, throws
  *                        bad request error if the $skip or $top option
  *                        is not applicable for the requested resource. 
  */
 private function _processSkipAndTop()
 {
     $value = null;
     if ($this->_readSkipOrTopOption(ODataConstants::HTTPQUERY_STRING_SKIP, $value)) {
         $this->request->setSkipCount($value);
     }
     $pageSize = 0;
     $isPagingRequired = $this->_isSSPagingRequired();
     if ($isPagingRequired) {
         $pageSize = $this->request->getTargetResourceSetWrapper()->getResourceSetPageSize();
     }
     if ($this->_readSkipOrTopOption(ODataConstants::HTTPQUERY_STRING_TOP, $value)) {
         $this->request->setTopOptionCount($value);
         if ($isPagingRequired && $pageSize < $value) {
             //If $top is greater than or equal to page size,
             //we will need a $skiptoken and thus our response
             //will be 2.0
             $this->request->raiseResponseVersion(2, 0);
             $this->request->setTopCount($pageSize);
         } else {
             $this->request->setTopCount($value);
         }
     } else {
         if ($isPagingRequired) {
             $this->request->raiseResponseVersion(2, 0);
             $this->request->setTopCount($pageSize);
         }
     }
     if (!is_null($this->request->getSkipCount()) || !is_null($this->request->getTopCount())) {
         $this->_checkSetQueryApplicable();
     }
 }