API CHANGE: Updated SS_ListDecorator to implement the list inteface and extend ViewableData, rather than DataObjectSet.

This commit is contained in:
ajshort 2011-05-02 18:12:39 +10:00
parent 04e5dae22e
commit df87fd5a11

View File

@ -1,25 +1,27 @@
<?php
/**
* A base class for decorators that wrap around a list to provide additional
* functionality. It extends {@link DataObjectSet} so that places which expect
* a list are passed one.
* functionality. It passes through list methods to the underlying list
* implementation.
*
* @package sapphire
* @subpackage model
*/
abstract class SS_ListDecorator extends DataObjectSet {
abstract class SS_ListDecorator extends ViewableData implements SS_List {
protected $list;
public function __construct(DataObjectSet $list) {
$this->list = $list;
public function __construct(SS_List $list) {
$this->list = $list;
$this->failover = $this->list;
parent::__construct();
}
/**
* Returns the list this decorator wraps around.
*
* @return DataObjectSet
* @return SS_List
*/
public function getList() {
return $this->list;
@ -43,14 +45,6 @@ abstract class SS_ListDecorator extends DataObjectSet {
$this->list->offsetUnset($key);
}
public function destroy() {
$this->list->destroy();
}
public function emptyItems() {
$this->list->emptyItems();
}
public function toArray($index = null) {
return $this->list->toArray($index);
}
@ -59,38 +53,14 @@ abstract class SS_ListDecorator extends DataObjectSet {
return $this->list->toNestedArray($index);
}
public function push($item, $key = null) {
$this->list->push($item, $key);
}
public function insertFirst($item, $key = null) {
$this->list->insertFirst($item, $key);
}
public function unshift($item) {
$this->list->unshift($item);
}
public function shift() {
return $this->list->shift();
}
public function pop() {
return $this->list->pop();
public function add($item) {
$this->list->add($item);
}
public function remove($itemObject) {
$this->list->remove($itemObject);
}
public function replace($itemOld, $itemNew) {
$this->list->replace($itemOld, $itemNew);
}
public function merge($anotherSet){
$this->list->merge($anotherSet);
}
public function getRange($offset, $length) {
return $this->list->getRange($offset, $length);
}
@ -119,10 +89,6 @@ abstract class SS_ListDecorator extends DataObjectSet {
return $this->list->Count();
}
public function UL() {
return $this->list->UL();
}
public function forTemplate() {
return $this->list->forTemplate();
}
@ -139,59 +105,16 @@ abstract class SS_ListDecorator extends DataObjectSet {
return $this->list->column($value);
}
public function groupBy($index){
return $this->list->groupBy($index);
}
public function GroupedBy($index, $childControl = "Children") {
return $this->list->GroupedBy($index, $childControl);
}
public function buildNestedUL($nestingLevels, $ulExtraAttributes = '') {
return $this->list->buildNestedUL($nestingLevels, $ulExtraAttributes);
}
public function getChildrenAsUL($nestingLevels, $level = 0, $template = "<li id=\"record-\$ID\" class=\"\$EvenOdd\">\$Title", $ulExtraAttributes = null, &$itemCount = 0) {
return $this->list->getChildrenAsUL(
$nestingLevels,
$level,
$template,
$ulExtraAttributes,
$itemCount);
public function canSortBy($by) {
return $this->list->canSortBy($by);
}
public function sort($fieldname, $direction = "ASC") {
$this->list->sort($fieldname, $direction);
}
public function removeDuplicates($field = 'ID') {
$this->list->removeDuplicates($field);
}
public function debug() {
return $this->list->debug();
}
public function groupWithParents($groupField, $groupClassName, $sortParents = null, $parentField = 'ID', $collapse = false, $requiredParents = null) {
return $this->list->groupWithParents(
$groupField,
$groupClassName,
$sortParents,
$parentField,
$collapse,
$requiredParents);
}
public function addWithoutWrite($field) {
$this->list->addWithoutWrite($field);
}
public function containsIDs($idList) {
return $this->list->condaintsIDs($idList);
}
public function onlyContainsIDs($idList) {
return $this->list->onlyContainsIDs($idList);
}
}