Permalink
Browse files

MINOR : Update core docs to use DataList::create() rather than DataOb…

…ject::get()/get_one()/get_by_id() where appropriate - Trac#6891
  • Loading branch information...
normann authored and chillu committed Mar 19, 2012
1 parent 6fb95e0 commit 9e60225064d19eb20c2cf5f409aef73764fcc4bd
Showing with 19 additions and 20 deletions.
  1. +2 −2 forms/OptionsetField.php
  2. +1 −1 model/DataList.php
  3. +14 −15 model/DataObject.php
  4. +1 −1 model/DataQuery.php
  5. +1 −1 model/Versioned.php
View
@@ -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
@@ -658,7 +658,7 @@ public function getIDList() {
* *
* 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
@@ -309,7 +309,7 @@ function __construct($record = null, $isSingleton = false, $model = null) {
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 @@ public function getReverseAssociation($className) {
} }
/** /**
* @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 @@ public function buildSQL($filter = "", $sort = "", $limit = "", $join = "", $res
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 @@ public static function get($callerClass, $filter = "", $sort = "", $join = "", $
} }
/** /**
* @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 @@ public function Aggregate($class = null) {
} }
/** /**
* @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 @@ public function RelationshipAggregate($relationship) {
* @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 @@ static function reset() {
/** /**
* 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 @@ static function reset() {
* @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
@@ -145,7 +145,7 @@ function getFinalisedQuery() {
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
@@ -1006,7 +1006,7 @@ function isLatestVersion() {
} }
/** /**
* 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.

0 comments on commit 9e60225

Please sign in to comment.