示例#1
0
 /**
  * Process the $inlinecount option and update the request description.
  *
  * @return void
  * 
  * @throws ODataException Throws bad request error in the following cases
  *                          (1) If $inlinecount is disabled by the developer
  *                          (2) If both $count and $inlinecount specified
  *                          (3) If $inlinecount value is unknown
  *                          (4) If capability negotiation over version fails
  */
 private function _processCount()
 {
     $inlineCount = $this->service->getHost()->getQueryStringItem(ODataConstants::HTTPQUERY_STRING_INLINECOUNT);
     //If it's not specified, we're done
     if (is_null($inlineCount)) {
         return;
     }
     //If the service doesn't allow count requests..then throw an exception
     if (!$this->service->getConfiguration()->getAcceptCountRequests()) {
         throw ODataException::createBadRequestError(Messages::configurationCountNotAccepted());
     }
     $inlineCount = trim($inlineCount);
     //if it's set to none, we don't do inline counts
     if ($inlineCount === ODataConstants::URI_ROWCOUNT_OFFOPTION) {
         return;
     }
     //You can't specify $count & $inlinecount together
     //TODO: ensure there's a test for this case see #55
     if ($this->request->queryType == QueryType::COUNT()) {
         throw ODataException::createBadRequestError(Messages::queryProcessorInlineCountWithValueCount());
     }
     $this->_checkSetQueryApplicable();
     //TODO: why do we do this check?
     if ($inlineCount === ODataConstants::URI_ROWCOUNT_ALLOPTION) {
         $this->request->queryType = QueryType::ENTITIES_WITH_COUNT();
         $this->request->raiseMinVersionRequirement(2, 0);
         $this->request->raiseResponseVersion(2, 0);
     } else {
         throw ODataException::createBadRequestError(Messages::queryProcessorInvalidInlineCountOptionError());
     }
 }