API CHANGE: Replaced DataObjectSet instances with ArrayList.

This commit is contained in:
ajshort 2011-05-05 20:40:24 +10:00
parent 9f87294427
commit 3f132a105b
30 changed files with 87 additions and 87 deletions

View File

@ -116,7 +116,7 @@ class CMSBatchActionHandler extends RequestHandler {
} }
} }
} else { } else {
$pages = new DataObjectSet(); $pages = new ArrayList();
} }
return $actionHandler->run($pages); return $actionHandler->run($pages);
@ -173,7 +173,7 @@ class CMSBatchActionHandler extends RequestHandler {
*/ */
function batchActionList() { function batchActionList() {
$actions = $this->batchActions(); $actions = $this->batchActions();
$actionList = new DataObjectSet(); $actionList = new ArrayList();
foreach($actions as $urlSegment => $action) { foreach($actions as $urlSegment => $action) {
$actionClass = $action['class']; $actionClass = $action['class'];

View File

@ -382,10 +382,10 @@ class LeftAndMain extends Controller {
*/ */
public function MainMenu() { public function MainMenu() {
// Don't accidentally return a menu if you're not logged in - it's used to determine access. // Don't accidentally return a menu if you're not logged in - it's used to determine access.
if(!Member::currentUser()) return new DataObjectSet(); if(!Member::currentUser()) return new ArrayList();
// Encode into DO set // Encode into DO set
$menu = new DataObjectSet(); $menu = new ArrayList();
$menuItems = CMSMenu::get_viewable_menu_items(); $menuItems = CMSMenu::get_viewable_menu_items();
if($menuItems) foreach($menuItems as $code => $menuItem) { if($menuItems) foreach($menuItems as $code => $menuItem) {
// alternate permission checks (in addition to LeftAndMain->canView()) // alternate permission checks (in addition to LeftAndMain->canView())

View File

@ -248,7 +248,7 @@ abstract class ModelAdmin extends LeftAndMain {
*/ */
protected function getModelForms() { protected function getModelForms() {
$models = $this->getManagedModels(); $models = $this->getManagedModels();
$forms = new DataObjectSet(); $forms = new ArrayList();
foreach($models as $class => $options) { foreach($models as $class => $options) {
if(is_numeric($class)) $class = $options; if(is_numeric($class)) $class = $options;
@ -476,11 +476,11 @@ class ModelAdmin_CollectionController extends Controller {
$importerClass = $importers[$modelName]; $importerClass = $importers[$modelName];
$importer = new $importerClass($modelName); $importer = new $importerClass($modelName);
$spec = $importer->getImportSpec(); $spec = $importer->getImportSpec();
$specFields = new DataObjectSet(); $specFields = new ArrayList();
foreach($spec['fields'] as $name => $desc) { foreach($spec['fields'] as $name => $desc) {
$specFields->push(new ArrayData(array('Name' => $name, 'Description' => $desc))); $specFields->push(new ArrayData(array('Name' => $name, 'Description' => $desc)));
} }
$specRelations = new DataObjectSet(); $specRelations = new ArrayList();
foreach($spec['relations'] as $name => $desc) { foreach($spec['relations'] as $name => $desc) {
$specRelations->push(new ArrayData(array('Name' => $name, 'Description' => $desc))); $specRelations->push(new ArrayData(array('Name' => $name, 'Description' => $desc)));
} }

View File

@ -137,7 +137,7 @@ class RSSFeed extends ViewableData {
* @return DataObjectSet Returns the {@link RSSFeed_Entry} objects. * @return DataObjectSet Returns the {@link RSSFeed_Entry} objects.
*/ */
function Entries() { function Entries() {
$output = new DataObjectSet(); $output = new ArrayList();
if(isset($this->entries)) { if(isset($this->entries)) {
foreach($this->entries as $entry) { foreach($this->entries as $entry) {
$output->push(new RSSFeed_Entry($entry, $this->titleField, $this->descriptionField, $this->authorField)); $output->push(new RSSFeed_Entry($entry, $this->titleField, $this->descriptionField, $this->authorField));

View File

@ -246,7 +246,7 @@ class RestfulServer extends Controller {
return $responseFormatter->convertDataObjectSet($obj, $fields); return $responseFormatter->convertDataObjectSet($obj, $fields);
} else if(!$obj) { } else if(!$obj) {
$responseFormatter->setTotalSize(0); $responseFormatter->setTotalSize(0);
return $responseFormatter->convertDataObjectSet(new DataObjectSet(), $fields); return $responseFormatter->convertDataObjectSet(new ArrayList(), $fields);
} else { } else {
return $responseFormatter->convertDataObject($obj, $fields); return $responseFormatter->convertDataObject($obj, $fields);
} }

View File

@ -250,7 +250,7 @@ class RestfulService extends ViewableData {
public function getAttributes($xml, $collection=NULL, $element=NULL){ public function getAttributes($xml, $collection=NULL, $element=NULL){
$xml = new SimpleXMLElement($xml); $xml = new SimpleXMLElement($xml);
$output = new DataObjectSet(); $output = new ArrayList();
if($collection) if($collection)
$childElements = $xml->{$collection}; $childElements = $xml->{$collection};
@ -305,7 +305,7 @@ class RestfulService extends ViewableData {
public function getValues($xml, $collection=NULL, $element=NULL){ public function getValues($xml, $collection=NULL, $element=NULL){
$xml = new SimpleXMLElement($xml); $xml = new SimpleXMLElement($xml);
$output = new DataObjectSet(); $output = new ArrayList();
$childElements = $xml; $childElements = $xml;
if($collection) if($collection)
@ -386,7 +386,7 @@ class RestfulService extends ViewableData {
*/ */
function searchAttributes($xml, $node=NULL){ function searchAttributes($xml, $node=NULL){
$xml = new SimpleXMLElement($xml); $xml = new SimpleXMLElement($xml);
$output = new DataObjectSet(); $output = new ArrayList();
$childElements = $xml->xpath($node); $childElements = $xml->xpath($node);

View File

@ -65,12 +65,12 @@ class SapphireSoapServer extends Controller {
} }
$methods[] = new ArrayData(array( $methods[] = new ArrayData(array(
"Name" => $methodName, "Name" => $methodName,
"Arguments" => new DataObjectSet($processedArguments), "Arguments" => new ArrayList($processedArguments),
"ReturnType" => self::$xsd_types[$returnType], "ReturnType" => self::$xsd_types[$returnType],
)); ));
} }
return new DataObjectSet($methods); return new ArrayList($methods);
} }
/** /**

View File

@ -165,7 +165,7 @@ class PaginatedList extends SS_ListDecorator {
* @return DataObjectSet * @return DataObjectSet
*/ */
public function Pages($max = null) { public function Pages($max = null) {
$result = new DataObjectSet(); $result = new ArrayList();
if ($max) { if ($max) {
$start = ($this->CurrentPage() - floor($max / 2)) - 1; $start = ($this->CurrentPage() - floor($max / 2)) - 1;
@ -232,7 +232,7 @@ class PaginatedList extends SS_ListDecorator {
* @return DataObjectSet * @return DataObjectSet
*/ */
public function PaginationSummary($context = 4) { public function PaginationSummary($context = 4) {
$result = new DataObjectSet(); $result = new ArrayList();
$current = $this->CurrentPage(); $current = $this->CurrentPage();
$total = $this->TotalPages(); $total = $this->TotalPages();

View File

@ -399,7 +399,7 @@ class BulkLoader_Result extends Object {
* @return DataObjectSet * @return DataObjectSet
*/ */
protected function mapToDataObjectSet($arr) { protected function mapToDataObjectSet($arr) {
$set = new DataObjectSet(); $set = new ArrayList();
foreach($arr as $arrItem) { foreach($arr as $arrItem) {
$obj = DataObject::get_by_id($arrItem['ClassName'], $arrItem['ID']); $obj = DataObject::get_by_id($arrItem['ClassName'], $arrItem['ID']);
$obj->_BulkLoaderMessage = $arrItem['Message']; $obj->_BulkLoaderMessage = $arrItem['Message'];

View File

@ -43,7 +43,7 @@ class ModelViewer extends Controller {
function Models() { function Models() {
$classes = ClassInfo::subclassesFor('DataObject'); $classes = ClassInfo::subclassesFor('DataObject');
array_shift($classes); array_shift($classes);
$output = new DataObjectSet(); $output = new ArrayList();
foreach($classes as $class) { foreach($classes as $class) {
$output->push(new ModelViewer_Model($class)); $output->push(new ModelViewer_Model($class));
} }
@ -60,7 +60,7 @@ class ModelViewer extends Controller {
$modules = array(); $modules = array();
foreach($classes as $class) { foreach($classes as $class) {
$model = new ModelViewer_Model($class); $model = new ModelViewer_Model($class);
if(!isset($modules[$model->Module])) $modules[$model->Module] = new DataObjectSet(); if(!isset($modules[$model->Module])) $modules[$model->Module] = new ArrayList();
$modules[$model->Module]->push($model); $modules[$model->Module]->push($model);
} }
ksort($modules); ksort($modules);
@ -70,7 +70,7 @@ class ModelViewer extends Controller {
$modules = array($this->module => $modules[$this->module]); $modules = array($this->module => $modules[$this->module]);
} }
$output = new DataObjectSet(); $output = new ArrayList();
foreach($modules as $moduleName => $models) { foreach($modules as $moduleName => $models) {
$output->push(new ArrayData(array( $output->push(new ArrayData(array(
'Link' => 'dev/viewmodel/' . $moduleName, 'Link' => 'dev/viewmodel/' . $moduleName,
@ -149,7 +149,7 @@ class ModelViewer_Model extends ViewableData {
} }
function Fields() { function Fields() {
$output = new DataObjectSet(); $output = new ArrayList();
$output->push(new ModelViewer_Field($this,'ID', 'PrimaryKey')); $output->push(new ModelViewer_Field($this,'ID', 'PrimaryKey'));
if(!$this->ParentModel) { if(!$this->ParentModel) {
@ -165,7 +165,7 @@ class ModelViewer_Model extends ViewableData {
} }
function Relations() { function Relations() {
$output = new DataObjectSet(); $output = new ArrayList();
foreach(array('has_one','has_many','many_many') as $relType) { foreach(array('has_one','has_many','many_many') as $relType) {
$items = singleton($this->className)->uninherited($relType,true); $items = singleton($this->className)->uninherited($relType,true);

View File

@ -256,7 +256,7 @@ JS;
$pageStart = (isset($_REQUEST['ctf'][$this->Name()]['start']) && is_numeric($_REQUEST['ctf'][$this->Name()]['start'])) ? $_REQUEST['ctf'][$this->Name()]['start'] : 0; $pageStart = (isset($_REQUEST['ctf'][$this->Name()]['start']) && is_numeric($_REQUEST['ctf'][$this->Name()]['start'])) ? $_REQUEST['ctf'][$this->Name()]['start'] : 0;
$output = new DataObjectSet(); $output = new ArrayList();
foreach($sourceItems as $pageIndex=>$item) { foreach($sourceItems as $pageIndex=>$item) {
$output->push(Object::create($this->itemClass,$item, $this, $pageStart+$pageIndex)); $output->push(Object::create($this->itemClass,$item, $this, $pageStart+$pageIndex));
} }
@ -540,7 +540,7 @@ class ComplexTableField_ItemRequest extends TableListField_ItemRequest {
*/ */
/* this doesn't actually work :-( /* this doesn't actually work :-(
function Paginator() { function Paginator() {
$paginatingSet = new DataObjectSet(array($this->dataObj())); $paginatingSet = new ArrayList(array($this->dataObj()));
$start = isset($_REQUEST['ctf']['start']) ? $_REQUEST['ctf']['start'] : 0; $start = isset($_REQUEST['ctf']['start']) ? $_REQUEST['ctf']['start'] : 0;
$paginatingSet->setPageLimits($start, 1, $this->ctf->TotalCount()); $paginatingSet->setPageLimits($start, 1, $this->ctf->TotalCount());
return $paginatingSet; return $paginatingSet;
@ -715,7 +715,7 @@ class ComplexTableField_ItemRequest extends TableListField_ItemRequest {
function Pagination() { function Pagination() {
$this->pageSize = 9; $this->pageSize = 9;
$currentItem = $this->PopupCurrentItem(); $currentItem = $this->PopupCurrentItem();
$result = new DataObjectSet(); $result = new ArrayList();
if($currentItem < 6) { if($currentItem < 6) {
$offset = 1; $offset = 1;
} elseif($this->TotalCount() - $currentItem <= 4) { } elseif($this->TotalCount() - $currentItem <= 4) {

View File

@ -136,7 +136,7 @@ class OptionsetField extends DropdownField {
} }
function ExtraOptions() { function ExtraOptions() {
return new DataObjectSet(); return new ArrayList();
} }
} }
?> ?>

View File

@ -74,7 +74,7 @@ class SelectionGroup extends CompositeField {
$firstSelected = $checked =""; $firstSelected = $checked ="";
} }
return new DataObjectSet($newItems); return new ArrayList($newItems);
} }
function hasData() { function hasData() {

View File

@ -128,7 +128,7 @@ class TableField extends TableListField {
$headings[] = new ArrayData(array("Name" => $fieldName, "Title" => $fieldTitle, "Class" => $class)); $headings[] = new ArrayData(array("Name" => $fieldName, "Title" => $fieldTitle, "Class" => $class));
$i++; $i++;
} }
return new DataObjectSet($headings); return new ArrayList($headings);
} }
/** /**
@ -151,14 +151,14 @@ class TableField extends TableListField {
*/ */
function Items() { function Items() {
// holds TableField_Item instances // holds TableField_Item instances
$items = new DataObjectSet(); $items = new ArrayList();
$sourceItems = $this->sourceItems(); $sourceItems = $this->sourceItems();
// either load all rows from the field value, // either load all rows from the field value,
// (e.g. when validation failed), or from sourceItems() // (e.g. when validation failed), or from sourceItems()
if($this->value) { if($this->value) {
if(!$sourceItems) $sourceItems = new DataObjectSet(); if(!$sourceItems) $sourceItems = new ArrayList();
// get an array keyed by rows, rather than values // get an array keyed by rows, rather than values
$rows = $this->sortData(ArrayLib::invert($this->value)); $rows = $this->sortData(ArrayLib::invert($this->value));
@ -221,7 +221,7 @@ class TableField extends TableListField {
); );
$form->loadDataFrom($dataObj); $form->loadDataFrom($dataObj);
// Add the item to our new DataObjectSet, with a wrapper class. // Add the item to our new ArrayList, with a wrapper class.
return new TableField_Item($dataObj, $this, $form, $this->fieldTypes); return new TableField_Item($dataObj, $this, $form, $this->fieldTypes);
} }

View File

@ -338,7 +338,7 @@ JS
"SortDirection" => (isset($_REQUEST['ctf'][$this->Name()]['dir'])) ? $_REQUEST['ctf'][$this->Name()]['dir'] : null "SortDirection" => (isset($_REQUEST['ctf'][$this->Name()]['dir'])) ? $_REQUEST['ctf'][$this->Name()]['dir'] : null
)); ));
} }
return new DataObjectSet($headings); return new ArrayList($headings);
} }
function disableSorting($to = true) { function disableSorting($to = true) {
@ -367,7 +367,7 @@ JS
* @return DataObjectSet * @return DataObjectSet
*/ */
function Actions() { function Actions() {
$allowedActions = new DataObjectSet(); $allowedActions = new ArrayList();
foreach($this->actions as $actionName => $actionSettings) { foreach($this->actions as $actionName => $actionSettings) {
if($this->Can($actionName)) { if($this->Can($actionName)) {
$allowedActions->push(new ViewableData()); $allowedActions->push(new ViewableData());
@ -437,7 +437,7 @@ JS
* Return a DataObjectSet of TableListField_Item objects, suitable for display in the template. * Return a DataObjectSet of TableListField_Item objects, suitable for display in the template.
*/ */
function Items() { function Items() {
$fieldItems = new DataObjectSet(); $fieldItems = new ArrayList();
if($items = $this->sourceItems()) foreach($items as $item) { if($items = $this->sourceItems()) foreach($items as $item) {
if($item) $fieldItems->push(new $this->itemClass($item, $this)); if($item) $fieldItems->push(new $this->itemClass($item, $this));
} }
@ -630,7 +630,7 @@ JS
'Title' => DBField::create('Varchar', $fieldTitle), 'Title' => DBField::create('Varchar', $fieldTitle),
)); ));
} }
return new DataObjectSet($summaryFields); return new ArrayList($summaryFields);
} }
function HasGroupedItems() { function HasGroupedItems() {
@ -648,9 +648,9 @@ JS
} }
$groupedItems = $items->groupBy($this->groupByField); $groupedItems = $items->groupBy($this->groupByField);
$groupedArrItems = new DataObjectSet(); $groupedArrItems = new ArrayList();
foreach($groupedItems as $key => $group) { foreach($groupedItems as $key => $group) {
$fieldItems = new DataObjectSet(); $fieldItems = new ArrayList();
foreach($group as $item) { foreach($group as $item) {
if($item) $fieldItems->push(new $this->itemClass($item, $this)); if($item) $fieldItems->push(new $this->itemClass($item, $this));
} }
@ -961,7 +961,7 @@ JS
$csvColumns = ($this->fieldListCsv) ? $this->fieldListCsv : $this->fieldList; $csvColumns = ($this->fieldListCsv) ? $this->fieldListCsv : $this->fieldList;
$fileData = ''; $fileData = '';
$columnData = array(); $columnData = array();
$fieldItems = new DataObjectSet(); $fieldItems = new ArrayList();
if($this->csvHasHeader) { if($this->csvHasHeader) {
$fileData .= "\"" . implode("\"{$separator}\"", array_values($csvColumns)) . "\""; $fileData .= "\"" . implode("\"{$separator}\"", array_values($csvColumns)) . "\"";
@ -1064,7 +1064,7 @@ JS
* ################################# * #################################
*/ */
function Utility() { function Utility() {
$links = new DataObjectSet(); $links = new ArrayList();
if($this->can('export')) { if($this->can('export')) {
$links->push(new ArrayData(array( $links->push(new ArrayData(array(
'Title' => _t('TableListField.CSVEXPORT', 'Export to CSV'), 'Title' => _t('TableListField.CSVEXPORT', 'Export to CSV'),
@ -1280,7 +1280,7 @@ JS
function SelectOptions(){ function SelectOptions(){
if(!$this->selectOptions) return; if(!$this->selectOptions) return;
$selectOptionsSet = new DataObjectSet(); $selectOptionsSet = new ArrayList();
foreach($this->selectOptions as $k => $v) { foreach($this->selectOptions as $k => $v) {
$selectOptionsSet->push(new ArrayData(array( $selectOptionsSet->push(new ArrayData(array(
'Key' => $k, 'Key' => $k,
@ -1377,7 +1377,7 @@ class TableListField_Item extends ViewableData {
"CsvSeparator" => $this->parent->getCsvSeparator(), "CsvSeparator" => $this->parent->getCsvSeparator(),
)); ));
} }
return new DataObjectSet($fields); return new ArrayList($fields);
} }
function Markable() { function Markable() {
@ -1430,7 +1430,7 @@ class TableListField_Item extends ViewableData {
* @return DataObjectSet * @return DataObjectSet
*/ */
function Actions() { function Actions() {
$allowedActions = new DataObjectSet(); $allowedActions = new ArrayList();
foreach($this->parent->actions as $actionName => $actionSettings) { foreach($this->parent->actions as $actionName => $actionSettings) {
if($this->parent->Can($actionName)) { if($this->parent->Can($actionName)) {
$allowedActions->push(new ArrayData(array( $allowedActions->push(new ArrayData(array(

View File

@ -59,7 +59,7 @@ class TreeMultiselectField extends TreeDropdownField {
// Otherwise, look data up from the linked relation // Otherwise, look data up from the linked relation
} if($this->value != 'unchanged' && is_string($this->value)) { } if($this->value != 'unchanged' && is_string($this->value)) {
$items = new DataObjectSet(); $items = new ArrayList();
$ids = explode(',', $this->value); $ids = explode(',', $this->value);
foreach($ids as $id) { foreach($ids as $id) {
if(!is_numeric($id)) continue; if(!is_numeric($id)) continue;

View File

@ -96,7 +96,7 @@ class DataDifferencer extends ViewableData {
* - To: The newer version of the field * - To: The newer version of the field
*/ */
function ChangedFields() { function ChangedFields() {
$changedFields = new DataObjectSet(); $changedFields = new ArrayList();
if($this->fromRecord) { if($this->fromRecord) {
$base = $this->fromRecord; $base = $this->fromRecord;

View File

@ -400,7 +400,7 @@ class Hierarchy extends DataExtension {
if(!(isset($this->_cache_children) && $this->_cache_children)) { if(!(isset($this->_cache_children) && $this->_cache_children)) {
$result = $this->owner->stageChildren(false); $result = $this->owner->stageChildren(false);
if(isset($result)) { if(isset($result)) {
$this->_cache_children = new DataObjectSet(); $this->_cache_children = new ArrayList();
foreach($result as $child) { foreach($result as $child) {
if($child->canView()) { if($child->canView()) {
$this->_cache_children->push($child); $this->_cache_children->push($child);
@ -452,7 +452,7 @@ class Hierarchy extends DataExtension {
// Next, go through the live children. Only some of these will be listed // Next, go through the live children. Only some of these will be listed
$liveChildren = $this->owner->liveChildren(true, true); $liveChildren = $this->owner->liveChildren(true, true);
if($liveChildren) { if($liveChildren) {
$merged = new DataObjectSet(); $merged = new ArrayList();
$merged->merge($stageChildren); $merged->merge($stageChildren);
$merged->merge($liveChildren); $merged->merge($liveChildren);
$stageChildren = $merged; $stageChildren = $merged;
@ -590,7 +590,7 @@ class Hierarchy extends DataExtension {
* @return DataObjectSet * @return DataObjectSet
*/ */
public function getAncestors() { public function getAncestors() {
$ancestors = new DataObjectSet(); $ancestors = new ArrayList();
$object = $this->owner; $object = $this->owner;
while($object = $object->getParent()) { while($object = $object->getParent()) {

View File

@ -829,8 +829,8 @@ class MySQLDatabase extends SS_Database {
$objects[] = new $record['ClassName']($record); $objects[] = new $record['ClassName']($record);
if(isset($objects)) $doSet = new DataObjectSet($objects); if(isset($objects)) $doSet = new ArrayList($objects);
else $doSet = new DataObjectSet(); else $doSet = new ArrayList();
$list = new PaginatedList($doSet); $list = new PaginatedList($doSet);
$list->setPageStart($start); $list->setPageStart($start);

View File

@ -68,7 +68,7 @@ class SQLMap extends Object implements IteratorAggregate {
*/ */
protected function genItems() { protected function genItems() {
if(!isset($this->items)) { if(!isset($this->items)) {
$this->items = new DataObjectSet(); $this->items = new ArrayList();
$items = $this->query->execute(); $items = $this->query->execute();
foreach($items as $item) { foreach($items as $item) {

View File

@ -700,7 +700,7 @@ class Versioned extends DataExtension {
$query->orderby = ($sort) ? $sort : "\"{$baseTable}_versions\".\"LastEdited\" DESC, \"{$baseTable}_versions\".\"Version\" DESC"; $query->orderby = ($sort) ? $sort : "\"{$baseTable}_versions\".\"LastEdited\" DESC, \"{$baseTable}_versions\".\"Version\" DESC";
$records = $query->execute(); $records = $query->execute();
$versions = new DataObjectSet(); $versions = new ArrayList();
foreach($records as $record) { foreach($records as $record) {
$versions->push(new Versioned_Version($record)); $versions->push(new Versioned_Version($record));

View File

@ -31,7 +31,7 @@ class Int extends DBField {
} }
function Times() { function Times() {
$output = new DataObjectSet(); $output = new ArrayList();
for( $i = 0; $i < $this->value; $i++ ) for( $i = 0; $i < $this->value; $i++ )
$output->push( new ArrayData( array( 'Number' => $i + 1 ) ) ); $output->push( new ArrayData( array( 'Number' => $i + 1 ) ) );

View File

@ -60,7 +60,7 @@ class BBCodeParser extends TextParser {
static function usable_tags() { static function usable_tags() {
return new DataObjectSet( return new ArrayList(
new ArrayData(array( new ArrayData(array(
"Title" => _t('BBCodeParser.BOLD', 'Bold Text'), "Title" => _t('BBCodeParser.BOLD', 'Bold Text'),
"Example" => '[b]<b>'._t('BBCodeParser.BOLDEXAMPLE', 'Bold').'</b>[/b]' "Example" => '[b]<b>'._t('BBCodeParser.BOLDEXAMPLE', 'Bold').'</b>[/b]'

View File

@ -42,7 +42,7 @@ class Group extends DataObject {
} }
function getAllChildren() { function getAllChildren() {
$doSet = new DataObjectSet(); $doSet = new ArrayList();
if ($children = DataObject::get('Group', '"ParentID" = '.$this->ID)) { if ($children = DataObject::get('Group', '"ParentID" = '.$this->ID)) {
foreach($children as $child) { foreach($children as $child) {
@ -137,7 +137,7 @@ class Group extends DataObject {
// Add roles (and disable all checkboxes for inherited roles) // Add roles (and disable all checkboxes for inherited roles)
$allRoles = Permission::check('ADMIN') ? DataObject::get('PermissionRole') : DataObject::get('PermissionRole', 'OnlyAdminCanApply = 0'); $allRoles = Permission::check('ADMIN') ? DataObject::get('PermissionRole') : DataObject::get('PermissionRole', 'OnlyAdminCanApply = 0');
$groupRoles = $this->Roles(); $groupRoles = $this->Roles();
$inheritedRoles = new DataObjectSet(); $inheritedRoles = new ArrayList();
$ancestors = $this->getAncestors(); $ancestors = $this->getAncestors();
foreach($ancestors as $ancestor) { foreach($ancestors as $ancestor) {
$ancestorRoles = $ancestor->Roles(); $ancestorRoles = $ancestor->Roles();
@ -399,7 +399,7 @@ class Group extends DataObject {
$children = $extInstance->AllChildrenIncludingDeleted(); $children = $extInstance->AllChildrenIncludingDeleted();
$extInstance->clearOwner(); $extInstance->clearOwner();
$filteredChildren = new DataObjectSet(); $filteredChildren = new ArrayList();
if($children) foreach($children as $child) { if($children) foreach($children as $child) {
if($child->canView()) $filteredChildren->push($child); if($child->canView()) $filteredChildren->push($child);

View File

@ -379,7 +379,7 @@ class Permission extends DataObject {
*/ */
public static function get_members_by_permission($code) { public static function get_members_by_permission($code) {
$toplevelGroups = self::get_groups_by_permission($code); $toplevelGroups = self::get_groups_by_permission($code);
if (!$toplevelGroups) return new DataObjectSet(); if (!$toplevelGroups) return new ArrayList();
$groupIDs = array(); $groupIDs = array();
foreach($toplevelGroups as $group) { foreach($toplevelGroups as $group) {
@ -389,7 +389,7 @@ class Permission extends DataObject {
} }
} }
if(!count($groupIDs)) return new DataObjectSet(); if(!count($groupIDs)) return new ArrayList();
$members = DataObject::get( $members = DataObject::get(
Object::getCustomClass('Member'), Object::getCustomClass('Member'),

View File

@ -45,7 +45,7 @@ class PermissionCheckboxSetField extends FormField {
if($records instanceof SS_List) { if($records instanceof SS_List) {
$this->records = $records; $this->records = $records;
} elseif($records instanceof Group) { } elseif($records instanceof Group) {
$this->records = new DataObjectSet($records); $this->records = new ArrayList(array($records));
} elseif($records) { } elseif($records) {
throw new InvalidArgumentException('$record should be either a Group record, or a DataObjectSet of Group records'); throw new InvalidArgumentException('$record should be either a Group record, or a DataObjectSet of Group records');
} }
@ -76,7 +76,7 @@ class PermissionCheckboxSetField extends FormField {
$uninheritedCodes = array(); $uninheritedCodes = array();
$inheritedCodes = array(); $inheritedCodes = array();
$records = ($this->records) ? $this->records : new DataObjectSet(); $records = ($this->records) ? $this->records : new ArrayList();
// Get existing values from the form record (assuming the formfield name is a join field on the record) // Get existing values from the form record (assuming the formfield name is a join field on the record)
if(is_object($this->form)) { if(is_object($this->form)) {

View File

@ -8,7 +8,7 @@ class RSSFeedTest extends SapphireTest {
protected static $original_host; protected static $original_host;
function testRSSFeed() { function testRSSFeed() {
$list = new DataObjectSet(); $list = new ArrayList();
$list->push(new RSSFeedTest_ItemA()); $list->push(new RSSFeedTest_ItemA());
$list->push(new RSSFeedTest_ItemB()); $list->push(new RSSFeedTest_ItemB());
$list->push(new RSSFeedTest_ItemC()); $list->push(new RSSFeedTest_ItemC());

View File

@ -304,7 +304,7 @@ class TableListFieldTest extends SapphireTest {
$three = new TableListFieldTest_Obj; $three = new TableListFieldTest_Obj;
$three->A = "A-three"; $three->A = "A-three";
$list = new DataObjectSet($one, $two, $three); $list = new ArrayList(array($one, $two, $three));
// A TableListField must be inside a form for its links to be generated // A TableListField must be inside a form for its links to be generated
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldSet( $form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldSet(

View File

@ -8,27 +8,27 @@
class PaginatedListTest extends SapphireTest { class PaginatedListTest extends SapphireTest {
public function testPageStart() { public function testPageStart() {
$list = new PaginatedList(new DataObjectSet()); $list = new PaginatedList(new ArrayList());
$this->assertEquals(0, $list->getPageStart(), 'The start defaults to 0.'); $this->assertEquals(0, $list->getPageStart(), 'The start defaults to 0.');
$list->setPageStart(10); $list->setPageStart(10);
$this->assertEquals(10, $list->getPageStart(), 'You can set the page start.'); $this->assertEquals(10, $list->getPageStart(), 'You can set the page start.');
$list = new PaginatedList(new DataObjectSet(), array('start' => 50)); $list = new PaginatedList(new ArrayList(), array('start' => 50));
$this->assertEquals(50, $list->getPageStart(), 'The page start can be read from the request.'); $this->assertEquals(50, $list->getPageStart(), 'The page start can be read from the request.');
} }
public function testGetTotalItems() { public function testGetTotalItems() {
$list = new PaginatedList(new DataObjectSet()); $list = new PaginatedList(new ArrayList());
$this->assertEquals(0, $list->getTotalItems()); $this->assertEquals(0, $list->getTotalItems());
$list->setTotalItems(10); $list->setTotalItems(10);
$this->assertEquals(10, $list->getTotalItems()); $this->assertEquals(10, $list->getTotalItems());
$list = new PaginatedList(new DataObjectSet( $list = new PaginatedList(new ArrayList(array(
new ArrayData(array()), new ArrayData(array()),
new ArrayData(array()) new ArrayData(array())
)); )));
$this->assertEquals(2, $list->getTotalItems()); $this->assertEquals(2, $list->getTotalItems());
} }
@ -39,7 +39,7 @@ class PaginatedListTest extends SapphireTest {
->method('unlimitedRowCount') ->method('unlimitedRowCount')
->will($this->returnValue(100)); ->will($this->returnValue(100));
$list = new PaginatedList(new DataObjectSet()); $list = new PaginatedList(new ArrayList());
$list->setPaginationFromQuery($query); $list->setPaginationFromQuery($query);
$this->assertEquals(15, $list->getPageLength()); $this->assertEquals(15, $list->getPageLength());
@ -48,7 +48,7 @@ class PaginatedListTest extends SapphireTest {
} }
public function testSetCurrentPage() { public function testSetCurrentPage() {
$list = new PaginatedList(new DataObjectSet()); $list = new PaginatedList(new ArrayList());
$list->setPageLength(10); $list->setPageLength(10);
$list->setCurrentPage(10); $list->setCurrentPage(10);
@ -57,7 +57,7 @@ class PaginatedListTest extends SapphireTest {
} }
public function testGetIterator() { public function testGetIterator() {
$list = new PaginatedList(new DataObjectSet(array( $list = new PaginatedList(new ArrayList(array(
new DataObject(array('Num' => 1)), new DataObject(array('Num' => 1)),
new DataObject(array('Num' => 2)), new DataObject(array('Num' => 2)),
new DataObject(array('Num' => 3)), new DataObject(array('Num' => 3)),
@ -85,7 +85,7 @@ class PaginatedListTest extends SapphireTest {
} }
public function testPages() { public function testPages() {
$list = new PaginatedList(new DataObjectSet()); $list = new PaginatedList(new ArrayList());
$list->setPageLength(10); $list->setPageLength(10);
$list->setTotalItems(50); $list->setTotalItems(50);
@ -113,7 +113,7 @@ class PaginatedListTest extends SapphireTest {
} }
public function testPaginationSummary() { public function testPaginationSummary() {
$list = new PaginatedList(new DataObjectSet()); $list = new PaginatedList(new ArrayList());
$list->setPageLength(10); $list->setPageLength(10);
$list->setTotalItems(250); $list->setTotalItems(250);
@ -134,7 +134,7 @@ class PaginatedListTest extends SapphireTest {
} }
public function testCurrentPage() { public function testCurrentPage() {
$list = new PaginatedList(new DataObjectSet()); $list = new PaginatedList(new ArrayList());
$list->setTotalItems(50); $list->setTotalItems(50);
$this->assertEquals(1, $list->CurrentPage()); $this->assertEquals(1, $list->CurrentPage());
@ -145,7 +145,7 @@ class PaginatedListTest extends SapphireTest {
} }
public function testTotalPages() { public function testTotalPages() {
$list = new PaginatedList(new DataObjectSet()); $list = new PaginatedList(new ArrayList());
$list->setPageLength(1); $list->setPageLength(1);
$this->assertEquals(0, $list->TotalPages()); $this->assertEquals(0, $list->TotalPages());
@ -158,7 +158,7 @@ class PaginatedListTest extends SapphireTest {
} }
public function testMoreThanOnePage() { public function testMoreThanOnePage() {
$list = new PaginatedList(new DataObjectSet()); $list = new PaginatedList(new ArrayList());
$list->setPageLength(1); $list->setPageLength(1);
$list->setTotalItems(1); $list->setTotalItems(1);
@ -169,14 +169,14 @@ class PaginatedListTest extends SapphireTest {
} }
public function testNotFirstPage() { public function testNotFirstPage() {
$list = new PaginatedList(new DataObjectSet()); $list = new PaginatedList(new ArrayList());
$this->assertFalse($list->NotFirstPage()); $this->assertFalse($list->NotFirstPage());
$list->setCurrentPage(2); $list->setCurrentPage(2);
$this->assertTrue($list->NotFirstPage()); $this->assertTrue($list->NotFirstPage());
} }
public function testNotLastPage() { public function testNotLastPage() {
$list = new PaginatedList(new DataObjectSet()); $list = new PaginatedList(new ArrayList());
$list->setTotalItems(50); $list->setTotalItems(50);
$this->assertTrue($list->NotLastPage()); $this->assertTrue($list->NotLastPage());
@ -185,14 +185,14 @@ class PaginatedListTest extends SapphireTest {
} }
public function testFirstItem() { public function testFirstItem() {
$list = new PaginatedList(new DataObjectSet()); $list = new PaginatedList(new ArrayList());
$this->assertEquals(1, $list->FirstItem()); $this->assertEquals(1, $list->FirstItem());
$list->setPageStart(10); $list->setPageStart(10);
$this->assertEquals(11, $list->FirstItem()); $this->assertEquals(11, $list->FirstItem());
} }
public function testLastItem() { public function testLastItem() {
$list = new PaginatedList(new DataObjectSet()); $list = new PaginatedList(new ArrayList());
$list->setPageLength(10); $list->setPageLength(10);
$list->setTotalItems(25); $list->setTotalItems(25);
@ -205,19 +205,19 @@ class PaginatedListTest extends SapphireTest {
} }
public function testFirstLink() { public function testFirstLink() {
$list = new PaginatedList(new DataObjectSet()); $list = new PaginatedList(new ArrayList());
$this->assertContains('start=0', $list->FirstLink()); $this->assertContains('start=0', $list->FirstLink());
} }
public function testLastLink() { public function testLastLink() {
$list = new PaginatedList(new DataObjectSet()); $list = new PaginatedList(new ArrayList());
$list->setPageLength(10); $list->setPageLength(10);
$list->setTotalItems(100); $list->setTotalItems(100);
$this->assertContains('start=90', $list->LastLink()); $this->assertContains('start=90', $list->LastLink());
} }
public function testNextLink() { public function testNextLink() {
$list = new PaginatedList(new DataObjectSet()); $list = new PaginatedList(new ArrayList());
$list->setTotalItems(50); $list->setTotalItems(50);
$this->assertContains('start=10', $list->NextLink()); $this->assertContains('start=10', $list->NextLink());
@ -232,7 +232,7 @@ class PaginatedListTest extends SapphireTest {
} }
public function testPrevLink() { public function testPrevLink() {
$list = new PaginatedList(new DataObjectSet()); $list = new PaginatedList(new ArrayList());
$list->setTotalItems(50); $list->setTotalItems(50);
$this->assertNull($list->PrevLink()); $this->assertNull($list->PrevLink());

View File

@ -332,10 +332,10 @@ after')
$data = new ArrayData(array( $data = new ArrayData(array(
'Title' => 'A', 'Title' => 'A',
'Children' => new DataObjectSet(array( 'Children' => new ArrayList(array(
new ArrayData(array( new ArrayData(array(
'Title' => 'A1', 'Title' => 'A1',
'Children' => new DataObjectSet(array( 'Children' => new ArrayList(array(
new ArrayData(array( 'Title' => 'A1 i', )), new ArrayData(array( 'Title' => 'A1 i', )),
new ArrayData(array( 'Title' => 'A1 ii', )), new ArrayData(array( 'Title' => 'A1 ii', )),
)), )),
@ -415,7 +415,7 @@ after')
// Data to run the loop tests on - one sequence of three items, each with a subitem // Data to run the loop tests on - one sequence of three items, each with a subitem
$data = new ArrayData(array( $data = new ArrayData(array(
'Name' => 'Top', 'Name' => 'Top',
'Foo' => new DataObjectSet(array( 'Foo' => new ArrayList(array(
new ArrayData(array( new ArrayData(array(
'Name' => '1', 'Name' => '1',
'Sub' => new ArrayData(array( 'Sub' => new ArrayData(array(
@ -538,7 +538,7 @@ class SSViewerTestFixture extends ViewableData {
// Special field name Loop### to create a list // Special field name Loop### to create a list
if(preg_match('/^Loop([0-9]+)$/', $fieldName, $matches)) { if(preg_match('/^Loop([0-9]+)$/', $fieldName, $matches)) {
$output = new DataObjectSet(); $output = new ArrayList();
for($i=0;$i<$matches[1];$i++) $output->push(new SSViewerTestFixture($childName)); for($i=0;$i<$matches[1];$i++) $output->push(new SSViewerTestFixture($childName));
return $output; return $output;