Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Commit

Permalink
Merge pull request #2296 from njam/model-paging-getItems
Browse files Browse the repository at this point in the history
Make sure to iterate over all items when instantiating models in paging
  • Loading branch information
fvovan authored Aug 22, 2016
2 parents 37ffdbb + 78847ff commit 2a4a66d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
42 changes: 21 additions & 21 deletions library/CM/Paging/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,30 +336,10 @@ protected function _processItem($itemRaw) {
return $itemRaw;
}

/**
* @param mixed $item
* @return boolean Whether the item is matched by any of the registered filters
*/
private function _isFilterMatch($item) {
foreach ($this->_filters as $filter) {
if (false === $filter($item)) {
return true;
}
}
return false;
}

/**
* @return bool
*/
private function _hasFilters() {
return count($this->_filters) > 0;
}

/**
* @return array Raw items (might contain more than $this->_pageSize)
*/
private function _getItemsRaw() {
protected function _getItemsRaw() {
if ($this->_itemsRaw === null) {
$this->_itemsRaw = array();
if ($this->_source) {
Expand All @@ -378,6 +358,26 @@ private function _getItemsRaw() {
return $this->_itemsRaw;
}

/**
* @param mixed $item
* @return boolean Whether the item is matched by any of the registered filters
*/
private function _isFilterMatch($item) {
foreach ($this->_filters as $filter) {
if (false === $filter($item)) {
return true;
}
}
return false;
}

/**
* @return bool
*/
private function _hasFilters() {
return count($this->_filters) > 0;
}

/**
* @return int OR null if no pageSize set
*/
Expand Down
2 changes: 1 addition & 1 deletion library/CM/Paging/ModelAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected function _populateModelList(array $itemsRaw) {

protected function _processItem($itemRaw) {
if (null === $this->_modelList) {
$this->_populateModelList($this->getItemsRaw());
$this->_populateModelList($this->_getItemsRaw());
}
$index = serialize($itemRaw);
if (null === ($model = $this->_modelList[$index])) {
Expand Down

0 comments on commit 2a4a66d

Please sign in to comment.