mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR : Update core docs to use DataList::create() rather than DataObject::get()/get_one()/get_by_id() where appropriate - Trac#6891
This commit is contained in:
parent
6fb95e098d
commit
9e60225064
@ -28,10 +28,10 @@
|
||||
*
|
||||
* <code>
|
||||
* //Database request for the object
|
||||
* $myDoSet = DataObject::get("FooBars","");
|
||||
* $myDoSet = DataList::create("FooBars","");
|
||||
* if($myDoSet){
|
||||
* // This returns an array of ID => Title
|
||||
* $map = $myDoSet->toDropDownMap();
|
||||
* $map = $myDoSet->map();
|
||||
*
|
||||
* // Instantiate the OptionsetField
|
||||
* $FieldList = new FieldList(
|
||||
|
@ -658,7 +658,7 @@ class DataList extends ViewableData implements SS_List, SS_Filterable, SS_Sortab
|
||||
*
|
||||
* Example: Get members from all Groups:
|
||||
*
|
||||
* DataObject::get("Group")->relation("Members")
|
||||
* DataList::Create("Group")->relation("Members")
|
||||
*
|
||||
* @param string $relationName
|
||||
* @return HasManyList|ManyManyList
|
||||
|
@ -309,7 +309,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
else $passed = "The value '$record'";
|
||||
|
||||
user_error("DataObject::__construct passed $passed. It's supposed to be passed an array,
|
||||
taken straight from the database. Perhaps you should use DataObject::get_one instead?", E_USER_WARNING);
|
||||
taken straight from the database. Perhaps you should use DataList::create()->First(); instead?", E_USER_WARNING);
|
||||
$record = null;
|
||||
}
|
||||
|
||||
@ -2469,10 +2469,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 3.0 Use DataObject::get and DataList to do your querying
|
||||
* @deprecated 3.0 Use DataList::create and DataList to do your querying
|
||||
*/
|
||||
public function buildSQL($filter = "", $sort = "", $limit = "", $join = "", $restrictClasses = true, $having = "") {
|
||||
Deprecation::notice('3.0', 'Use DataObject::get and DataList to do your querying instead.');
|
||||
Deprecation::notice('3.0', 'Use DataList::create and DataList to do your querying instead.');
|
||||
return $this->extendedSQL($filter, $sort, $limit, $join, $having);
|
||||
|
||||
}
|
||||
@ -2483,10 +2483,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
private static $cache_buildSQL_query;
|
||||
|
||||
/**
|
||||
* @deprecated 3.0 Use DataObject::get and DataList to do your querying
|
||||
* @deprecated 3.0 Use DataList::create and DataList to do your querying
|
||||
*/
|
||||
public function extendedSQL($filter = "", $sort = "", $limit = "", $join = ""){
|
||||
Deprecation::notice('3.0', 'Use DataObject::get and DataList to do your querying instead.');
|
||||
Deprecation::notice('3.0', 'Use DataList::create and DataList to do your querying instead.');
|
||||
$dataList = DataObject::get($this->class, $filter, $sort, $join, $limit);
|
||||
return $dataList->dataQuery()->query();
|
||||
}
|
||||
@ -2521,10 +2521,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 3.0 Use DataObject::get and DataList to do your querying
|
||||
* @deprecated 3.0 Use DataList::create and DataList to do your querying
|
||||
*/
|
||||
public function Aggregate($class = null) {
|
||||
Deprecation::notice('3.0', 'Use DataObject::get and DataList to do your querying instead.');
|
||||
Deprecation::notice('3.0', 'Use DataList::create and DataList to do your querying instead.');
|
||||
|
||||
if($class) {
|
||||
$list = new DataList($class);
|
||||
@ -2538,19 +2538,18 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 3.0 Use DataObject::get and DataList to do your querying
|
||||
* @deprecated 3.0 Use DataList::create and DataList to do your querying
|
||||
*/
|
||||
public function RelationshipAggregate($relationship) {
|
||||
Deprecation::notice('3.0', 'Use DataObject::get and DataList to do your querying instead.');
|
||||
Deprecation::notice('3.0', 'Use DataList::create and DataList to do your querying instead.');
|
||||
|
||||
return $this->$relationship();
|
||||
}
|
||||
|
||||
/**
|
||||
* The internal function that actually performs the querying for get().
|
||||
* DataObject::get("Table","filter") is the same as singleton("Table")->instance_get("filter")
|
||||
* DataList::create("Table")->where("filter") is the same as singleton("Table")->instance_get("filter")
|
||||
*
|
||||
* @deprecated 3.0 Use DataObject::get and DataList to do your querying
|
||||
* @deprecated 3.0 Use DataList::create and DataList to do your querying
|
||||
*
|
||||
* @param string $filter A filter to be inserted into the WHERE clause.
|
||||
* @param string $sort A sort expression to be inserted into the ORDER BY clause. If omitted, self::$default_sort will be used.
|
||||
@ -2561,7 +2560,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* @return mixed The objects matching the filter, in the class specified by $containerClass
|
||||
*/
|
||||
public function instance_get($filter = "", $sort = "", $join = "", $limit="", $containerClass = "DataObjectSet") {
|
||||
Deprecation::notice('3.0', 'Use DataObject::get and DataList to do your querying instead.');
|
||||
Deprecation::notice('3.0', 'Use DataList::create and DataList to do your querying instead.');
|
||||
return self::get($this->class, $filter, $sort, $join, $limit, $containerClass);
|
||||
}
|
||||
|
||||
@ -2693,7 +2692,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
/**
|
||||
* Does the hard work for get_one()
|
||||
*
|
||||
* @deprecated 3.0 Use DataObject::get_one() instead
|
||||
* @deprecated 3.0 Use DataList::create($this->class)->where($filter)->sort($orderby)->First() instead
|
||||
*
|
||||
* @uses DataExtension->augmentSQL()
|
||||
*
|
||||
@ -2702,7 +2701,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* @return DataObject The first item matching the query
|
||||
*/
|
||||
public function instance_get_one($filter, $orderby = null) {
|
||||
Deprecation::notice('3.0', 'Use DataObject::get_one() instead.');
|
||||
Deprecation::notice('3.0', 'Use DataList::create($this->class)->where($filter)->sort($orderby)->First() instead.');
|
||||
return DataObject::get_one($this->class, $filter, true, $orderby);
|
||||
}
|
||||
|
||||
|
@ -145,7 +145,7 @@ class DataQuery {
|
||||
if($this->dataClass != $baseClass) {
|
||||
// Get the ClassName values to filter to
|
||||
$classNames = ClassInfo::subclassesFor($this->dataClass);
|
||||
if(!$classNames) user_error("DataObject::get() Can't find data sub-classes for '$callerClass'");
|
||||
if(!$classNames) user_error("DataList::create() Can't find data sub-classes for '$callerClass'");
|
||||
$query->where[] = "\"$baseClass\".\"ClassName\" IN ('" . implode("','", $classNames) . "')";
|
||||
}
|
||||
}
|
||||
|
@ -1006,7 +1006,7 @@ class Versioned extends DataExtension {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the equivalent of a DataObject::get() call, querying the latest
|
||||
* Return the equivalent of a DataList::create() call, querying the latest
|
||||
* version of each page stored in the (class)_versions tables.
|
||||
*
|
||||
* In particular, this will query deleted records as well as active ones.
|
||||
|
Loading…
Reference in New Issue
Block a user