ENHANCEMENT Merge pull request #6499 from SilbinaryWolf/feat-decoratorsetlist

feat(ListDecorator): Add setList() function. Useful for keeping a decorator/paginated list configuration intact while modifying the underlying list.
This commit is contained in:
Damian Mooyman 2017-01-13 21:51:18 +13:00 committed by GitHub
commit 88f90bfc79

View File

@ -15,8 +15,7 @@ abstract class SS_ListDecorator extends ViewableData implements SS_List, SS_Sort
protected $list;
public function __construct(SS_List $list) {
$this->list = $list;
$this->failover = $this->list;
$this->setList($list);
parent::__construct();
}
@ -30,6 +29,21 @@ abstract class SS_ListDecorator extends ViewableData implements SS_List, SS_Sort
return $this->list;
}
/**
* Set the list this decorator wraps around.
*
* Useful for keeping a decorator/paginated list configuration intact while modifying
* the underlying list.
*
* @return SS_List
*/
public function setList(SS_List $list)
{
$this->list = $list;
$this->failover = $this->list;
return $this;
}
// PROXIED METHODS ---------------------------------------------------------
public function offsetExists($key) {