feat(ListDecorator): Add setList() function. Useful for keeping a decorator/paginated list configuration intact while modifying the underlying list.

This commit is contained in:
Jake Bentvelzen 2017-01-13 15:03:47 +11:00
parent 733511565e
commit c7586c68b7

View File

@ -15,8 +15,7 @@ abstract class SS_ListDecorator extends ViewableData implements SS_List, SS_Sort
protected $list; protected $list;
public function __construct(SS_List $list) { public function __construct(SS_List $list) {
$this->list = $list; $this->setList($list);
$this->failover = $this->list;
parent::__construct(); parent::__construct();
} }
@ -30,6 +29,21 @@ abstract class SS_ListDecorator extends ViewableData implements SS_List, SS_Sort
return $this->list; 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 --------------------------------------------------------- // PROXIED METHODS ---------------------------------------------------------
public function offsetExists($key) { public function offsetExists($key) {