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:
Normann Lou 2012-03-19 15:27:52 +13:00 committed by Ingo Schommer
parent 6fb95e098d
commit 9e60225064
5 changed files with 19 additions and 20 deletions

View File

@ -28,10 +28,10 @@
* *
* <code> * <code>
* //Database request for the object * //Database request for the object
* $myDoSet = DataObject::get("FooBars",""); * $myDoSet = DataList::create("FooBars","");
* if($myDoSet){ * if($myDoSet){
* // This returns an array of ID => Title * // This returns an array of ID => Title
* $map = $myDoSet->toDropDownMap(); * $map = $myDoSet->map();
* *
* // Instantiate the OptionsetField * // Instantiate the OptionsetField
* $FieldList = new FieldList( * $FieldList = new FieldList(

View File

@ -658,7 +658,7 @@ class DataList extends ViewableData implements SS_List, SS_Filterable, SS_Sortab
* *
* Example: Get members from all Groups: * Example: Get members from all Groups:
* *
* DataObject::get("Group")->relation("Members") * DataList::Create("Group")->relation("Members")
* *
* @param string $relationName * @param string $relationName
* @return HasManyList|ManyManyList * @return HasManyList|ManyManyList

View File

@ -309,7 +309,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
else $passed = "The value '$record'"; else $passed = "The value '$record'";
user_error("DataObject::__construct passed $passed. It's supposed to be passed an array, 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; $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 = "") { 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); return $this->extendedSQL($filter, $sort, $limit, $join, $having);
} }
@ -2483,10 +2483,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
private static $cache_buildSQL_query; 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 = ""){ 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); $dataList = DataObject::get($this->class, $filter, $sort, $join, $limit);
return $dataList->dataQuery()->query(); 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) { 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) { if($class) {
$list = new DataList($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) { 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(); return $this->$relationship();
} }
/** /**
* The internal function that actually performs the querying for get(). * DataList::create("Table")->where("filter") is the same as singleton("Table")->instance_get("filter")
* DataObject::get("Table","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 $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. * @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 * @return mixed The objects matching the filter, in the class specified by $containerClass
*/ */
public function instance_get($filter = "", $sort = "", $join = "", $limit="", $containerClass = "DataObjectSet") { 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); 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() * 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() * @uses DataExtension->augmentSQL()
* *
@ -2702,7 +2701,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
* @return DataObject The first item matching the query * @return DataObject The first item matching the query
*/ */
public function instance_get_one($filter, $orderby = null) { 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); return DataObject::get_one($this->class, $filter, true, $orderby);
} }

View File

@ -145,7 +145,7 @@ class DataQuery {
if($this->dataClass != $baseClass) { if($this->dataClass != $baseClass) {
// Get the ClassName values to filter to // Get the ClassName values to filter to
$classNames = ClassInfo::subclassesFor($this->dataClass); $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) . "')"; $query->where[] = "\"$baseClass\".\"ClassName\" IN ('" . implode("','", $classNames) . "')";
} }
} }

View File

@ -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. * version of each page stored in the (class)_versions tables.
* *
* In particular, this will query deleted records as well as active ones. * In particular, this will query deleted records as well as active ones.