mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE: Replaced DataObjectSet instances with ArrayList.
This commit is contained in:
parent
9f87294427
commit
3f132a105b
@ -116,7 +116,7 @@ class CMSBatchActionHandler extends RequestHandler {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$pages = new DataObjectSet();
|
||||
$pages = new ArrayList();
|
||||
}
|
||||
|
||||
return $actionHandler->run($pages);
|
||||
@ -173,7 +173,7 @@ class CMSBatchActionHandler extends RequestHandler {
|
||||
*/
|
||||
function batchActionList() {
|
||||
$actions = $this->batchActions();
|
||||
$actionList = new DataObjectSet();
|
||||
$actionList = new ArrayList();
|
||||
|
||||
foreach($actions as $urlSegment => $action) {
|
||||
$actionClass = $action['class'];
|
||||
|
@ -382,10 +382,10 @@ class LeftAndMain extends Controller {
|
||||
*/
|
||||
public function MainMenu() {
|
||||
// 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
|
||||
$menu = new DataObjectSet();
|
||||
$menu = new ArrayList();
|
||||
$menuItems = CMSMenu::get_viewable_menu_items();
|
||||
if($menuItems) foreach($menuItems as $code => $menuItem) {
|
||||
// alternate permission checks (in addition to LeftAndMain->canView())
|
||||
|
@ -248,7 +248,7 @@ abstract class ModelAdmin extends LeftAndMain {
|
||||
*/
|
||||
protected function getModelForms() {
|
||||
$models = $this->getManagedModels();
|
||||
$forms = new DataObjectSet();
|
||||
$forms = new ArrayList();
|
||||
|
||||
foreach($models as $class => $options) {
|
||||
if(is_numeric($class)) $class = $options;
|
||||
@ -476,11 +476,11 @@ class ModelAdmin_CollectionController extends Controller {
|
||||
$importerClass = $importers[$modelName];
|
||||
$importer = new $importerClass($modelName);
|
||||
$spec = $importer->getImportSpec();
|
||||
$specFields = new DataObjectSet();
|
||||
$specFields = new ArrayList();
|
||||
foreach($spec['fields'] as $name => $desc) {
|
||||
$specFields->push(new ArrayData(array('Name' => $name, 'Description' => $desc)));
|
||||
}
|
||||
$specRelations = new DataObjectSet();
|
||||
$specRelations = new ArrayList();
|
||||
foreach($spec['relations'] as $name => $desc) {
|
||||
$specRelations->push(new ArrayData(array('Name' => $name, 'Description' => $desc)));
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ class RSSFeed extends ViewableData {
|
||||
* @return DataObjectSet Returns the {@link RSSFeed_Entry} objects.
|
||||
*/
|
||||
function Entries() {
|
||||
$output = new DataObjectSet();
|
||||
$output = new ArrayList();
|
||||
if(isset($this->entries)) {
|
||||
foreach($this->entries as $entry) {
|
||||
$output->push(new RSSFeed_Entry($entry, $this->titleField, $this->descriptionField, $this->authorField));
|
||||
|
@ -246,7 +246,7 @@ class RestfulServer extends Controller {
|
||||
return $responseFormatter->convertDataObjectSet($obj, $fields);
|
||||
} else if(!$obj) {
|
||||
$responseFormatter->setTotalSize(0);
|
||||
return $responseFormatter->convertDataObjectSet(new DataObjectSet(), $fields);
|
||||
return $responseFormatter->convertDataObjectSet(new ArrayList(), $fields);
|
||||
} else {
|
||||
return $responseFormatter->convertDataObject($obj, $fields);
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ class RestfulService extends ViewableData {
|
||||
|
||||
public function getAttributes($xml, $collection=NULL, $element=NULL){
|
||||
$xml = new SimpleXMLElement($xml);
|
||||
$output = new DataObjectSet();
|
||||
$output = new ArrayList();
|
||||
|
||||
if($collection)
|
||||
$childElements = $xml->{$collection};
|
||||
@ -305,7 +305,7 @@ class RestfulService extends ViewableData {
|
||||
|
||||
public function getValues($xml, $collection=NULL, $element=NULL){
|
||||
$xml = new SimpleXMLElement($xml);
|
||||
$output = new DataObjectSet();
|
||||
$output = new ArrayList();
|
||||
|
||||
$childElements = $xml;
|
||||
if($collection)
|
||||
@ -386,7 +386,7 @@ class RestfulService extends ViewableData {
|
||||
*/
|
||||
function searchAttributes($xml, $node=NULL){
|
||||
$xml = new SimpleXMLElement($xml);
|
||||
$output = new DataObjectSet();
|
||||
$output = new ArrayList();
|
||||
|
||||
$childElements = $xml->xpath($node);
|
||||
|
||||
|
@ -65,12 +65,12 @@ class SapphireSoapServer extends Controller {
|
||||
}
|
||||
$methods[] = new ArrayData(array(
|
||||
"Name" => $methodName,
|
||||
"Arguments" => new DataObjectSet($processedArguments),
|
||||
"Arguments" => new ArrayList($processedArguments),
|
||||
"ReturnType" => self::$xsd_types[$returnType],
|
||||
));
|
||||
}
|
||||
|
||||
return new DataObjectSet($methods);
|
||||
return new ArrayList($methods);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -165,7 +165,7 @@ class PaginatedList extends SS_ListDecorator {
|
||||
* @return DataObjectSet
|
||||
*/
|
||||
public function Pages($max = null) {
|
||||
$result = new DataObjectSet();
|
||||
$result = new ArrayList();
|
||||
|
||||
if ($max) {
|
||||
$start = ($this->CurrentPage() - floor($max / 2)) - 1;
|
||||
@ -232,7 +232,7 @@ class PaginatedList extends SS_ListDecorator {
|
||||
* @return DataObjectSet
|
||||
*/
|
||||
public function PaginationSummary($context = 4) {
|
||||
$result = new DataObjectSet();
|
||||
$result = new ArrayList();
|
||||
$current = $this->CurrentPage();
|
||||
$total = $this->TotalPages();
|
||||
|
||||
|
@ -399,7 +399,7 @@ class BulkLoader_Result extends Object {
|
||||
* @return DataObjectSet
|
||||
*/
|
||||
protected function mapToDataObjectSet($arr) {
|
||||
$set = new DataObjectSet();
|
||||
$set = new ArrayList();
|
||||
foreach($arr as $arrItem) {
|
||||
$obj = DataObject::get_by_id($arrItem['ClassName'], $arrItem['ID']);
|
||||
$obj->_BulkLoaderMessage = $arrItem['Message'];
|
||||
|
@ -43,7 +43,7 @@ class ModelViewer extends Controller {
|
||||
function Models() {
|
||||
$classes = ClassInfo::subclassesFor('DataObject');
|
||||
array_shift($classes);
|
||||
$output = new DataObjectSet();
|
||||
$output = new ArrayList();
|
||||
foreach($classes as $class) {
|
||||
$output->push(new ModelViewer_Model($class));
|
||||
}
|
||||
@ -60,7 +60,7 @@ class ModelViewer extends Controller {
|
||||
$modules = array();
|
||||
foreach($classes as $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);
|
||||
}
|
||||
ksort($modules);
|
||||
@ -70,7 +70,7 @@ class ModelViewer extends Controller {
|
||||
$modules = array($this->module => $modules[$this->module]);
|
||||
}
|
||||
|
||||
$output = new DataObjectSet();
|
||||
$output = new ArrayList();
|
||||
foreach($modules as $moduleName => $models) {
|
||||
$output->push(new ArrayData(array(
|
||||
'Link' => 'dev/viewmodel/' . $moduleName,
|
||||
@ -149,7 +149,7 @@ class ModelViewer_Model extends ViewableData {
|
||||
}
|
||||
|
||||
function Fields() {
|
||||
$output = new DataObjectSet();
|
||||
$output = new ArrayList();
|
||||
|
||||
$output->push(new ModelViewer_Field($this,'ID', 'PrimaryKey'));
|
||||
if(!$this->ParentModel) {
|
||||
@ -165,7 +165,7 @@ class ModelViewer_Model extends ViewableData {
|
||||
}
|
||||
|
||||
function Relations() {
|
||||
$output = new DataObjectSet();
|
||||
$output = new ArrayList();
|
||||
|
||||
foreach(array('has_one','has_many','many_many') as $relType) {
|
||||
$items = singleton($this->className)->uninherited($relType,true);
|
||||
|
@ -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;
|
||||
|
||||
$output = new DataObjectSet();
|
||||
$output = new ArrayList();
|
||||
foreach($sourceItems as $pageIndex=>$item) {
|
||||
$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 :-(
|
||||
function Paginator() {
|
||||
$paginatingSet = new DataObjectSet(array($this->dataObj()));
|
||||
$paginatingSet = new ArrayList(array($this->dataObj()));
|
||||
$start = isset($_REQUEST['ctf']['start']) ? $_REQUEST['ctf']['start'] : 0;
|
||||
$paginatingSet->setPageLimits($start, 1, $this->ctf->TotalCount());
|
||||
return $paginatingSet;
|
||||
@ -715,7 +715,7 @@ class ComplexTableField_ItemRequest extends TableListField_ItemRequest {
|
||||
function Pagination() {
|
||||
$this->pageSize = 9;
|
||||
$currentItem = $this->PopupCurrentItem();
|
||||
$result = new DataObjectSet();
|
||||
$result = new ArrayList();
|
||||
if($currentItem < 6) {
|
||||
$offset = 1;
|
||||
} elseif($this->TotalCount() - $currentItem <= 4) {
|
||||
|
@ -136,7 +136,7 @@ class OptionsetField extends DropdownField {
|
||||
}
|
||||
|
||||
function ExtraOptions() {
|
||||
return new DataObjectSet();
|
||||
return new ArrayList();
|
||||
}
|
||||
}
|
||||
?>
|
@ -74,7 +74,7 @@ class SelectionGroup extends CompositeField {
|
||||
|
||||
$firstSelected = $checked ="";
|
||||
}
|
||||
return new DataObjectSet($newItems);
|
||||
return new ArrayList($newItems);
|
||||
}
|
||||
|
||||
function hasData() {
|
||||
|
@ -128,7 +128,7 @@ class TableField extends TableListField {
|
||||
$headings[] = new ArrayData(array("Name" => $fieldName, "Title" => $fieldTitle, "Class" => $class));
|
||||
$i++;
|
||||
}
|
||||
return new DataObjectSet($headings);
|
||||
return new ArrayList($headings);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -151,14 +151,14 @@ class TableField extends TableListField {
|
||||
*/
|
||||
function Items() {
|
||||
// holds TableField_Item instances
|
||||
$items = new DataObjectSet();
|
||||
$items = new ArrayList();
|
||||
|
||||
$sourceItems = $this->sourceItems();
|
||||
|
||||
// either load all rows from the field value,
|
||||
// (e.g. when validation failed), or from sourceItems()
|
||||
if($this->value) {
|
||||
if(!$sourceItems) $sourceItems = new DataObjectSet();
|
||||
if(!$sourceItems) $sourceItems = new ArrayList();
|
||||
|
||||
// get an array keyed by rows, rather than values
|
||||
$rows = $this->sortData(ArrayLib::invert($this->value));
|
||||
@ -221,7 +221,7 @@ class TableField extends TableListField {
|
||||
);
|
||||
$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);
|
||||
}
|
||||
|
||||
|
@ -338,7 +338,7 @@ JS
|
||||
"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) {
|
||||
@ -367,7 +367,7 @@ JS
|
||||
* @return DataObjectSet
|
||||
*/
|
||||
function Actions() {
|
||||
$allowedActions = new DataObjectSet();
|
||||
$allowedActions = new ArrayList();
|
||||
foreach($this->actions as $actionName => $actionSettings) {
|
||||
if($this->Can($actionName)) {
|
||||
$allowedActions->push(new ViewableData());
|
||||
@ -437,7 +437,7 @@ JS
|
||||
* Return a DataObjectSet of TableListField_Item objects, suitable for display in the template.
|
||||
*/
|
||||
function Items() {
|
||||
$fieldItems = new DataObjectSet();
|
||||
$fieldItems = new ArrayList();
|
||||
if($items = $this->sourceItems()) foreach($items as $item) {
|
||||
if($item) $fieldItems->push(new $this->itemClass($item, $this));
|
||||
}
|
||||
@ -630,7 +630,7 @@ JS
|
||||
'Title' => DBField::create('Varchar', $fieldTitle),
|
||||
));
|
||||
}
|
||||
return new DataObjectSet($summaryFields);
|
||||
return new ArrayList($summaryFields);
|
||||
}
|
||||
|
||||
function HasGroupedItems() {
|
||||
@ -648,9 +648,9 @@ JS
|
||||
}
|
||||
|
||||
$groupedItems = $items->groupBy($this->groupByField);
|
||||
$groupedArrItems = new DataObjectSet();
|
||||
$groupedArrItems = new ArrayList();
|
||||
foreach($groupedItems as $key => $group) {
|
||||
$fieldItems = new DataObjectSet();
|
||||
$fieldItems = new ArrayList();
|
||||
foreach($group as $item) {
|
||||
if($item) $fieldItems->push(new $this->itemClass($item, $this));
|
||||
}
|
||||
@ -961,7 +961,7 @@ JS
|
||||
$csvColumns = ($this->fieldListCsv) ? $this->fieldListCsv : $this->fieldList;
|
||||
$fileData = '';
|
||||
$columnData = array();
|
||||
$fieldItems = new DataObjectSet();
|
||||
$fieldItems = new ArrayList();
|
||||
|
||||
if($this->csvHasHeader) {
|
||||
$fileData .= "\"" . implode("\"{$separator}\"", array_values($csvColumns)) . "\"";
|
||||
@ -1064,7 +1064,7 @@ JS
|
||||
* #################################
|
||||
*/
|
||||
function Utility() {
|
||||
$links = new DataObjectSet();
|
||||
$links = new ArrayList();
|
||||
if($this->can('export')) {
|
||||
$links->push(new ArrayData(array(
|
||||
'Title' => _t('TableListField.CSVEXPORT', 'Export to CSV'),
|
||||
@ -1280,7 +1280,7 @@ JS
|
||||
function SelectOptions(){
|
||||
if(!$this->selectOptions) return;
|
||||
|
||||
$selectOptionsSet = new DataObjectSet();
|
||||
$selectOptionsSet = new ArrayList();
|
||||
foreach($this->selectOptions as $k => $v) {
|
||||
$selectOptionsSet->push(new ArrayData(array(
|
||||
'Key' => $k,
|
||||
@ -1377,7 +1377,7 @@ class TableListField_Item extends ViewableData {
|
||||
"CsvSeparator" => $this->parent->getCsvSeparator(),
|
||||
));
|
||||
}
|
||||
return new DataObjectSet($fields);
|
||||
return new ArrayList($fields);
|
||||
}
|
||||
|
||||
function Markable() {
|
||||
@ -1430,7 +1430,7 @@ class TableListField_Item extends ViewableData {
|
||||
* @return DataObjectSet
|
||||
*/
|
||||
function Actions() {
|
||||
$allowedActions = new DataObjectSet();
|
||||
$allowedActions = new ArrayList();
|
||||
foreach($this->parent->actions as $actionName => $actionSettings) {
|
||||
if($this->parent->Can($actionName)) {
|
||||
$allowedActions->push(new ArrayData(array(
|
||||
|
@ -59,7 +59,7 @@ class TreeMultiselectField extends TreeDropdownField {
|
||||
|
||||
// Otherwise, look data up from the linked relation
|
||||
} if($this->value != 'unchanged' && is_string($this->value)) {
|
||||
$items = new DataObjectSet();
|
||||
$items = new ArrayList();
|
||||
$ids = explode(',', $this->value);
|
||||
foreach($ids as $id) {
|
||||
if(!is_numeric($id)) continue;
|
||||
|
@ -96,7 +96,7 @@ class DataDifferencer extends ViewableData {
|
||||
* - To: The newer version of the field
|
||||
*/
|
||||
function ChangedFields() {
|
||||
$changedFields = new DataObjectSet();
|
||||
$changedFields = new ArrayList();
|
||||
|
||||
if($this->fromRecord) {
|
||||
$base = $this->fromRecord;
|
||||
|
@ -400,7 +400,7 @@ class Hierarchy extends DataExtension {
|
||||
if(!(isset($this->_cache_children) && $this->_cache_children)) {
|
||||
$result = $this->owner->stageChildren(false);
|
||||
if(isset($result)) {
|
||||
$this->_cache_children = new DataObjectSet();
|
||||
$this->_cache_children = new ArrayList();
|
||||
foreach($result as $child) {
|
||||
if($child->canView()) {
|
||||
$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
|
||||
$liveChildren = $this->owner->liveChildren(true, true);
|
||||
if($liveChildren) {
|
||||
$merged = new DataObjectSet();
|
||||
$merged = new ArrayList();
|
||||
$merged->merge($stageChildren);
|
||||
$merged->merge($liveChildren);
|
||||
$stageChildren = $merged;
|
||||
@ -590,7 +590,7 @@ class Hierarchy extends DataExtension {
|
||||
* @return DataObjectSet
|
||||
*/
|
||||
public function getAncestors() {
|
||||
$ancestors = new DataObjectSet();
|
||||
$ancestors = new ArrayList();
|
||||
$object = $this->owner;
|
||||
|
||||
while($object = $object->getParent()) {
|
||||
|
@ -829,8 +829,8 @@ class MySQLDatabase extends SS_Database {
|
||||
$objects[] = new $record['ClassName']($record);
|
||||
|
||||
|
||||
if(isset($objects)) $doSet = new DataObjectSet($objects);
|
||||
else $doSet = new DataObjectSet();
|
||||
if(isset($objects)) $doSet = new ArrayList($objects);
|
||||
else $doSet = new ArrayList();
|
||||
|
||||
$list = new PaginatedList($doSet);
|
||||
$list->setPageStart($start);
|
||||
|
@ -68,7 +68,7 @@ class SQLMap extends Object implements IteratorAggregate {
|
||||
*/
|
||||
protected function genItems() {
|
||||
if(!isset($this->items)) {
|
||||
$this->items = new DataObjectSet();
|
||||
$this->items = new ArrayList();
|
||||
$items = $this->query->execute();
|
||||
|
||||
foreach($items as $item) {
|
||||
|
@ -700,7 +700,7 @@ class Versioned extends DataExtension {
|
||||
$query->orderby = ($sort) ? $sort : "\"{$baseTable}_versions\".\"LastEdited\" DESC, \"{$baseTable}_versions\".\"Version\" DESC";
|
||||
|
||||
$records = $query->execute();
|
||||
$versions = new DataObjectSet();
|
||||
$versions = new ArrayList();
|
||||
|
||||
foreach($records as $record) {
|
||||
$versions->push(new Versioned_Version($record));
|
||||
|
@ -31,7 +31,7 @@ class Int extends DBField {
|
||||
}
|
||||
|
||||
function Times() {
|
||||
$output = new DataObjectSet();
|
||||
$output = new ArrayList();
|
||||
for( $i = 0; $i < $this->value; $i++ )
|
||||
$output->push( new ArrayData( array( 'Number' => $i + 1 ) ) );
|
||||
|
||||
|
@ -60,7 +60,7 @@ class BBCodeParser extends TextParser {
|
||||
|
||||
|
||||
static function usable_tags() {
|
||||
return new DataObjectSet(
|
||||
return new ArrayList(
|
||||
new ArrayData(array(
|
||||
"Title" => _t('BBCodeParser.BOLD', 'Bold Text'),
|
||||
"Example" => '[b]<b>'._t('BBCodeParser.BOLDEXAMPLE', 'Bold').'</b>[/b]'
|
||||
|
@ -42,7 +42,7 @@ class Group extends DataObject {
|
||||
}
|
||||
|
||||
function getAllChildren() {
|
||||
$doSet = new DataObjectSet();
|
||||
$doSet = new ArrayList();
|
||||
|
||||
if ($children = DataObject::get('Group', '"ParentID" = '.$this->ID)) {
|
||||
foreach($children as $child) {
|
||||
@ -137,7 +137,7 @@ class Group extends DataObject {
|
||||
// Add roles (and disable all checkboxes for inherited roles)
|
||||
$allRoles = Permission::check('ADMIN') ? DataObject::get('PermissionRole') : DataObject::get('PermissionRole', 'OnlyAdminCanApply = 0');
|
||||
$groupRoles = $this->Roles();
|
||||
$inheritedRoles = new DataObjectSet();
|
||||
$inheritedRoles = new ArrayList();
|
||||
$ancestors = $this->getAncestors();
|
||||
foreach($ancestors as $ancestor) {
|
||||
$ancestorRoles = $ancestor->Roles();
|
||||
@ -399,7 +399,7 @@ class Group extends DataObject {
|
||||
$children = $extInstance->AllChildrenIncludingDeleted();
|
||||
$extInstance->clearOwner();
|
||||
|
||||
$filteredChildren = new DataObjectSet();
|
||||
$filteredChildren = new ArrayList();
|
||||
|
||||
if($children) foreach($children as $child) {
|
||||
if($child->canView()) $filteredChildren->push($child);
|
||||
|
@ -379,7 +379,7 @@ class Permission extends DataObject {
|
||||
*/
|
||||
public static function get_members_by_permission($code) {
|
||||
$toplevelGroups = self::get_groups_by_permission($code);
|
||||
if (!$toplevelGroups) return new DataObjectSet();
|
||||
if (!$toplevelGroups) return new ArrayList();
|
||||
|
||||
$groupIDs = array();
|
||||
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(
|
||||
Object::getCustomClass('Member'),
|
||||
|
@ -45,7 +45,7 @@ class PermissionCheckboxSetField extends FormField {
|
||||
if($records instanceof SS_List) {
|
||||
$this->records = $records;
|
||||
} elseif($records instanceof Group) {
|
||||
$this->records = new DataObjectSet($records);
|
||||
$this->records = new ArrayList(array($records));
|
||||
} elseif($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();
|
||||
$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)
|
||||
if(is_object($this->form)) {
|
||||
|
@ -8,7 +8,7 @@ class RSSFeedTest extends SapphireTest {
|
||||
protected static $original_host;
|
||||
|
||||
function testRSSFeed() {
|
||||
$list = new DataObjectSet();
|
||||
$list = new ArrayList();
|
||||
$list->push(new RSSFeedTest_ItemA());
|
||||
$list->push(new RSSFeedTest_ItemB());
|
||||
$list->push(new RSSFeedTest_ItemC());
|
||||
|
@ -304,7 +304,7 @@ class TableListFieldTest extends SapphireTest {
|
||||
$three = new TableListFieldTest_Obj;
|
||||
$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
|
||||
$form = new Form(new TableListFieldTest_TestController(), "TestForm", new FieldSet(
|
||||
|
@ -8,27 +8,27 @@
|
||||
class PaginatedListTest extends SapphireTest {
|
||||
|
||||
public function testPageStart() {
|
||||
$list = new PaginatedList(new DataObjectSet());
|
||||
$list = new PaginatedList(new ArrayList());
|
||||
$this->assertEquals(0, $list->getPageStart(), 'The start defaults to 0.');
|
||||
|
||||
$list->setPageStart(10);
|
||||
$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.');
|
||||
}
|
||||
|
||||
public function testGetTotalItems() {
|
||||
$list = new PaginatedList(new DataObjectSet());
|
||||
$list = new PaginatedList(new ArrayList());
|
||||
$this->assertEquals(0, $list->getTotalItems());
|
||||
|
||||
$list->setTotalItems(10);
|
||||
$this->assertEquals(10, $list->getTotalItems());
|
||||
|
||||
$list = new PaginatedList(new DataObjectSet(
|
||||
$list = new PaginatedList(new ArrayList(array(
|
||||
new ArrayData(array()),
|
||||
new ArrayData(array())
|
||||
));
|
||||
)));
|
||||
$this->assertEquals(2, $list->getTotalItems());
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ class PaginatedListTest extends SapphireTest {
|
||||
->method('unlimitedRowCount')
|
||||
->will($this->returnValue(100));
|
||||
|
||||
$list = new PaginatedList(new DataObjectSet());
|
||||
$list = new PaginatedList(new ArrayList());
|
||||
$list->setPaginationFromQuery($query);
|
||||
|
||||
$this->assertEquals(15, $list->getPageLength());
|
||||
@ -48,7 +48,7 @@ class PaginatedListTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testSetCurrentPage() {
|
||||
$list = new PaginatedList(new DataObjectSet());
|
||||
$list = new PaginatedList(new ArrayList());
|
||||
$list->setPageLength(10);
|
||||
$list->setCurrentPage(10);
|
||||
|
||||
@ -57,7 +57,7 @@ class PaginatedListTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testGetIterator() {
|
||||
$list = new PaginatedList(new DataObjectSet(array(
|
||||
$list = new PaginatedList(new ArrayList(array(
|
||||
new DataObject(array('Num' => 1)),
|
||||
new DataObject(array('Num' => 2)),
|
||||
new DataObject(array('Num' => 3)),
|
||||
@ -85,7 +85,7 @@ class PaginatedListTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testPages() {
|
||||
$list = new PaginatedList(new DataObjectSet());
|
||||
$list = new PaginatedList(new ArrayList());
|
||||
$list->setPageLength(10);
|
||||
$list->setTotalItems(50);
|
||||
|
||||
@ -113,7 +113,7 @@ class PaginatedListTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testPaginationSummary() {
|
||||
$list = new PaginatedList(new DataObjectSet());
|
||||
$list = new PaginatedList(new ArrayList());
|
||||
|
||||
$list->setPageLength(10);
|
||||
$list->setTotalItems(250);
|
||||
@ -134,7 +134,7 @@ class PaginatedListTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testCurrentPage() {
|
||||
$list = new PaginatedList(new DataObjectSet());
|
||||
$list = new PaginatedList(new ArrayList());
|
||||
$list->setTotalItems(50);
|
||||
|
||||
$this->assertEquals(1, $list->CurrentPage());
|
||||
@ -145,7 +145,7 @@ class PaginatedListTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testTotalPages() {
|
||||
$list = new PaginatedList(new DataObjectSet());
|
||||
$list = new PaginatedList(new ArrayList());
|
||||
|
||||
$list->setPageLength(1);
|
||||
$this->assertEquals(0, $list->TotalPages());
|
||||
@ -158,7 +158,7 @@ class PaginatedListTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testMoreThanOnePage() {
|
||||
$list = new PaginatedList(new DataObjectSet());
|
||||
$list = new PaginatedList(new ArrayList());
|
||||
|
||||
$list->setPageLength(1);
|
||||
$list->setTotalItems(1);
|
||||
@ -169,14 +169,14 @@ class PaginatedListTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testNotFirstPage() {
|
||||
$list = new PaginatedList(new DataObjectSet());
|
||||
$list = new PaginatedList(new ArrayList());
|
||||
$this->assertFalse($list->NotFirstPage());
|
||||
$list->setCurrentPage(2);
|
||||
$this->assertTrue($list->NotFirstPage());
|
||||
}
|
||||
|
||||
public function testNotLastPage() {
|
||||
$list = new PaginatedList(new DataObjectSet());
|
||||
$list = new PaginatedList(new ArrayList());
|
||||
$list->setTotalItems(50);
|
||||
|
||||
$this->assertTrue($list->NotLastPage());
|
||||
@ -185,14 +185,14 @@ class PaginatedListTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testFirstItem() {
|
||||
$list = new PaginatedList(new DataObjectSet());
|
||||
$list = new PaginatedList(new ArrayList());
|
||||
$this->assertEquals(1, $list->FirstItem());
|
||||
$list->setPageStart(10);
|
||||
$this->assertEquals(11, $list->FirstItem());
|
||||
}
|
||||
|
||||
public function testLastItem() {
|
||||
$list = new PaginatedList(new DataObjectSet());
|
||||
$list = new PaginatedList(new ArrayList());
|
||||
$list->setPageLength(10);
|
||||
$list->setTotalItems(25);
|
||||
|
||||
@ -205,19 +205,19 @@ class PaginatedListTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testFirstLink() {
|
||||
$list = new PaginatedList(new DataObjectSet());
|
||||
$list = new PaginatedList(new ArrayList());
|
||||
$this->assertContains('start=0', $list->FirstLink());
|
||||
}
|
||||
|
||||
public function testLastLink() {
|
||||
$list = new PaginatedList(new DataObjectSet());
|
||||
$list = new PaginatedList(new ArrayList());
|
||||
$list->setPageLength(10);
|
||||
$list->setTotalItems(100);
|
||||
$this->assertContains('start=90', $list->LastLink());
|
||||
}
|
||||
|
||||
public function testNextLink() {
|
||||
$list = new PaginatedList(new DataObjectSet());
|
||||
$list = new PaginatedList(new ArrayList());
|
||||
$list->setTotalItems(50);
|
||||
|
||||
$this->assertContains('start=10', $list->NextLink());
|
||||
@ -232,7 +232,7 @@ class PaginatedListTest extends SapphireTest {
|
||||
}
|
||||
|
||||
public function testPrevLink() {
|
||||
$list = new PaginatedList(new DataObjectSet());
|
||||
$list = new PaginatedList(new ArrayList());
|
||||
$list->setTotalItems(50);
|
||||
|
||||
$this->assertNull($list->PrevLink());
|
||||
|
@ -332,10 +332,10 @@ after')
|
||||
|
||||
$data = new ArrayData(array(
|
||||
'Title' => 'A',
|
||||
'Children' => new DataObjectSet(array(
|
||||
'Children' => new ArrayList(array(
|
||||
new ArrayData(array(
|
||||
'Title' => 'A1',
|
||||
'Children' => new DataObjectSet(array(
|
||||
'Children' => new ArrayList(array(
|
||||
new ArrayData(array( 'Title' => 'A1 i', )),
|
||||
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 = new ArrayData(array(
|
||||
'Name' => 'Top',
|
||||
'Foo' => new DataObjectSet(array(
|
||||
'Foo' => new ArrayList(array(
|
||||
new ArrayData(array(
|
||||
'Name' => '1',
|
||||
'Sub' => new ArrayData(array(
|
||||
@ -538,7 +538,7 @@ class SSViewerTestFixture extends ViewableData {
|
||||
|
||||
// Special field name Loop### to create a list
|
||||
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));
|
||||
return $output;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user