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

Commit

Permalink
override _clearItems
Browse files Browse the repository at this point in the history
  • Loading branch information
fvovan committed Aug 22, 2016
1 parent 4c5e916 commit 3065a1a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
17 changes: 8 additions & 9 deletions library/CM/Paging/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,21 @@ public function setFlattenItems($state) {
$this->_flattenItems = (bool) $state;
}


/**
* @return bool
*/
protected function _canContainUnprocessableItems() {
return ($this->_getStalenessChance() != 0);
}

protected function _clearItems() {
$this->_items = array();
$this->_itemsRaw = null;
$this->_itemsRawTree = null;
$this->_iteratorPosition = 0;
$this->_iteratorItems = null;
}

/**
* @return int Multiple of items per page to load from CM_PagingSource_Abstract
*/
Expand Down Expand Up @@ -381,14 +388,6 @@ private function _getItemOffset() {
return (int) $this->_pageOffset * $this->_pageSize;
}

private function _clearItems() {
$this->_items = array();
$this->_itemsRaw = null;
$this->_itemsRawTree = null;
$this->_iteratorPosition = 0;
$this->_iteratorItems = null;
}

private function _clearCount() {
$this->_count = null;
}
Expand Down
10 changes: 2 additions & 8 deletions library/CM/Paging/ModelAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,8 @@ public function _change() {
$this->_modelList = null;
}

public function setPage($page, $size) {
parent::setPage($page, $size);
$this->_modelList = null;
return $this;
}

public function filter(Closure $filter) {
parent::filter($filter);
protected function _clearItems() {
parent::_clearItems();
$this->_modelList = null;
}

Expand Down
2 changes: 1 addition & 1 deletion tests/library/CM/Paging/ModelAbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testPagingVariableType() {
}
}

public function testPagedPaging() {
public function testModelListInvalidation() {
CM_Config::get()->CM_Model_Abstract->types[CM_Paging_ModelAbstractTest_ModelMock::getTypeStatic()] = 'CM_Paging_ModelAbstractTest_ModelMock';
CM_Config::get()->CM_Model_Abstract->types[CM_Paging_ModelAbstractTest_ModelMock2::getTypeStatic()] = 'CM_Paging_ModelAbstractTest_ModelMock2';
$model1 = CM_Paging_ModelAbstractTest_ModelMock::create('foo');
Expand Down

0 comments on commit 3065a1a

Please sign in to comment.