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


PHP DataList::limit方法代碼示例

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


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

示例1: sequenceGridListItems

 /**
  * @param \DataList|\ArrayList $items
  * @param                      $filters
  * @param array                $parameters
  */
 public function sequenceGridListItems(&$items, $filters, &$parameters = [])
 {
     $limit = isset($parameters['PageLength']) ? $parameters['PageLength'] : null;
     // filter items for each filter to current page length
     if ($limit) {
         $start = GridList::service()->Filters()->start() ?: 0;
         $out = new \ArrayList();
         $currentFilter = GridList::service()->constraint(Constraints::FilterVar);
         if ($currentFilter && $currentFilter != 'all') {
             if ($filter = GridListFilter::get()->filter(['ModelTag' => $currentFilter])->first()) {
                 $out->merge($items->limit($limit, $start));
             }
         } else {
             foreach ($filters as $filter) {
                 $filtered = new \ArrayList();
                 foreach ($items as $item) {
                     if ($item instanceof Block) {
                         // only push blocks first page
                         if ($start == 0) {
                             $filtered->push($item);
                         }
                     } else {
                         if ($currentFilter == 'all') {
                             $filtered->push($item);
                         } else {
                             if ($item->GridListFilters()->find('ID', $filter->ID)) {
                                 $filtered->push($item);
                             }
                         }
                     }
                 }
                 // merge limited filtered items back in
                 $out->merge($filtered->limit($limit, $start));
             }
         }
         $items = $out;
     }
 }
開發者ID:CrackerjackDigital,項目名稱:silverstripe-modular,代碼行數:43,代碼來源:Pagination.php

示例2: LimitGalleryItems

 /**
  * limits the number of displayed items
  *
  * @param DataList $galleryList
  * @return DataList|SS_Limitable
  */
 protected function LimitGalleryItems(DataList $galleryList)
 {
     $limit = Config::inst()->get('HeaderGalleryExtension', 'limit_header_images');
     return $limit ? $galleryList->limit($limit) : $galleryList;
 }
開發者ID:helpfulrobot,項目名稱:wernerkrauss-silverstripe-header-gallery,代碼行數:11,代碼來源:HeaderGalleryExtension.php

示例3: limitCurrentFinalProducts

 /**
  * limits the products to a maximum number (for speed's sake)
  * @return DataList (this->allProducts adjusted!)
  */
 protected function limitCurrentFinalProducts()
 {
     $this->rawCount = $this->allProducts->count();
     $max = EcommerceConfig::get("ProductGroup", "maximum_number_of_products_to_list");
     if ($this->rawCount > $max) {
         $this->allProducts = $this->allProducts->limit($max);
         $this->totalCount = $max;
     } else {
         $this->totalCount = $this->rawCount;
     }
     return $this->allProducts;
 }
開發者ID:abhibavishi,項目名稱:silverstripe-ecommerce,代碼行數:16,代碼來源:ProductGroup.php


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