mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Removing deprecated DataObject::buildDataObjectSet()
Use DataList API instead
This commit is contained in:
parent
dde820d87d
commit
a8d779b4de
@ -2738,42 +2738,6 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
return self::get($this->class, $filter, $sort, $join, $limit, $containerClass);
|
return self::get($this->class, $filter, $sort, $join, $limit, $containerClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Take a database {@link SS_Query} and instanciate an object for each record.
|
|
||||||
*
|
|
||||||
* @deprecated 3.0 Replaced by DataList
|
|
||||||
*
|
|
||||||
* @param SS_Query|array $records The database records, a {@link SS_Query} object or an array of maps.
|
|
||||||
* @param string $containerClass The class to place all of the objects into.
|
|
||||||
*
|
|
||||||
* @return mixed The new objects in an object of type $containerClass
|
|
||||||
*/
|
|
||||||
public function buildDataObjectSet($records, $containerClass = "DataObjectSet", $query = null, $baseClass = null) {
|
|
||||||
Deprecation::notice('3.0', 'Use DataList instead.');
|
|
||||||
|
|
||||||
foreach($records as $record) {
|
|
||||||
if(empty($record['RecordClassName'])) {
|
|
||||||
$record['RecordClassName'] = $record['ClassName'];
|
|
||||||
}
|
|
||||||
if(class_exists($record['RecordClassName'])) {
|
|
||||||
$results[] = new $record['RecordClassName']($record);
|
|
||||||
} else {
|
|
||||||
if(!$baseClass) {
|
|
||||||
user_error("Bad RecordClassName '{$record['RecordClassName']}' and "
|
|
||||||
. "\$baseClass not set", E_USER_ERROR);
|
|
||||||
} else if(!is_string($baseClass) || !class_exists($baseClass)) {
|
|
||||||
user_error("Bad RecordClassName '{$record['RecordClassName']}' and bad "
|
|
||||||
. "\$baseClass '$baseClass not set", E_USER_ERROR);
|
|
||||||
}
|
|
||||||
$results[] = new $baseClass($record);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isset($results)) {
|
|
||||||
return new $containerClass($results);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the first item matching the given query.
|
* Return the first item matching the given query.
|
||||||
* All calls to get_one() are cached.
|
* All calls to get_one() are cached.
|
||||||
|
Loading…
Reference in New Issue
Block a user