当前位置: 首页>>代码示例>>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;未经允许,请勿转载。