當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DataObjectSet::setPageLength方法代碼示例

本文整理匯總了PHP中DataObjectSet::setPageLength方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataObjectSet::setPageLength方法的具體用法?PHP DataObjectSet::setPageLength怎麽用?PHP DataObjectSet::setPageLength使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DataObjectSet的用法示例。


在下文中一共展示了DataObjectSet::setPageLength方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getDataObjects

 /**
  * Return all the dataobjects that were found in this query
  *
  * @param $evaluatePermissions
  *			Should we evaluate whether the user can view before adding the result to the dataset?
  *
  * @return DataObjectSet
  */
 public function getDataObjects($evaluatePermissions = false, $expandRawObjects = true)
 {
     if (!$this->dataObjects) {
         $this->dataObjects = ArrayList::create();
         $result = $this->getResult();
         $documents = $result && isset($result->response) ? $result->response : null;
         if ($documents && isset($documents->docs)) {
             $totalAdded = 0;
             foreach ($documents->docs as $doc) {
                 $bits = explode('_', $doc->id);
                 if (count($bits) == 3) {
                     list($type, $id, $stage) = $bits;
                 } else {
                     list($type, $id) = $bits;
                     $stage = Versioned::current_stage();
                 }
                 if (!$type || !$id) {
                     singleton('SolrUtils')->log("Invalid solr document ID {$doc->id}", SS_Log::WARN);
                     continue;
                 }
                 if (strpos($doc->id, SolrSearchService::RAW_DATA_KEY) === 0) {
                     $object = $this->inflateRawResult($doc, $expandRawObjects);
                     // $object = new ArrayData($data);
                 } else {
                     if (!class_exists($type)) {
                         continue;
                     }
                     // a double sanity check for the stage here.
                     if ($currentStage = Versioned::current_stage()) {
                         if ($currentStage != $stage) {
                             continue;
                         }
                     }
                     $object = DataObject::get_by_id($type, $id);
                 }
                 if ($object && $object->ID) {
                     // check that the user has permission
                     if (isset($doc->score)) {
                         $object->SearchScore = $doc->score;
                     }
                     $canAdd = true;
                     if ($evaluatePermissions) {
                         // check if we've got a way of evaluating perms
                         if ($object->hasMethod('canView')) {
                             $canAdd = $object->canView();
                         }
                     }
                     if (!$evaluatePermissions || $canAdd) {
                         if ($object->hasMethod('canShowInSearch')) {
                             if ($object->canShowInSearch()) {
                                 $this->dataObjects->push($object);
                             }
                         } else {
                             $this->dataObjects->push($object);
                         }
                     }
                     $totalAdded++;
                 } else {
                     singleton('SolrUtils')->log("Object {$doc->id} is no longer in the system, removing from index", SS_Log::WARN);
                     $this->solr->unindex($type, $id);
                 }
             }
             $this->totalResults = $documents->numFound;
             // update the dos with stats about this query
             $this->dataObjects = PaginatedList::create($this->dataObjects);
             $this->dataObjects->setPageLength($this->queryParameters->limit)->setPageStart($documents->start)->setTotalItems($documents->numFound)->setLimitItems(false);
             //				$paginatedSet->setPaginationFromQuery($set->dataQuery()->query());
             // $this->dataObjects->setPageLimits($documents->start, $this->queryParameters->limit, $documents->numFound);
         }
     }
     return $this->dataObjects;
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-solr,代碼行數:80,代碼來源:SolrResultSet.php


注:本文中的DataObjectSet::setPageLength方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。