本文整理匯總了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;
}
}
示例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;
}