Skip to content
This repository
Browse code

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...
commit 9e60225064d19eb20c2cf5f409aef73764fcc4bd 1 parent 6fb95e0
Normann Lou authored chillu committed
4  forms/OptionsetField.php
@@ -28,10 +28,10 @@
28 28
  * 
29 29
  * <code>
30 30
  * //Database request for the object
31  
- * $myDoSet = DataObject::get("FooBars","");
  31
+ * $myDoSet = DataList::create("FooBars","");
32 32
  * if($myDoSet){
33 33
  *  // This returns an array of ID => Title
34  
- *  $map = $myDoSet->toDropDownMap();
  34
+ *  $map = $myDoSet->map();
35 35
  *  
36 36
  *   // Instantiate the OptionsetField 
37 37
  *   $FieldList = new FieldList(
2  model/DataList.php
@@ -658,7 +658,7 @@ public function getIDList() {
658 658
 	 * 
659 659
 	 * Example: Get members from all Groups:
660 660
 	 * 
661  
-	 *     DataObject::get("Group")->relation("Members")
  661
+	 *     DataList::Create("Group")->relation("Members")
662 662
 	 * 
663 663
 	 * @param string $relationName
664 664
 	 * @return HasManyList|ManyManyList
29  model/DataObject.php
@@ -309,7 +309,7 @@ function __construct($record = null, $isSingleton = false, $model = null) {
309 309
 			else $passed = "The value '$record'";
310 310
 
311 311
 			user_error("DataObject::__construct passed $passed.  It's supposed to be passed an array,
312  
-			taken straight from the database.  Perhaps you should use DataObject::get_one instead?", E_USER_WARNING);
  312
+			taken straight from the database.  Perhaps you should use DataList::create()->First(); instead?", E_USER_WARNING);
313 313
 			$record = null;
314 314
 		}
315 315
 
@@ -2469,10 +2469,10 @@ public function getReverseAssociation($className) {
2469 2469
 	}
2470 2470
 
2471 2471
 	/**
2472  
-	 * @deprecated 3.0 Use DataObject::get and DataList to do your querying
  2472
+	 * @deprecated 3.0 Use DataList::create and DataList to do your querying
2473 2473
 	 */
2474 2474
 	public function buildSQL($filter = "", $sort = "", $limit = "", $join = "", $restrictClasses = true, $having = "") {
2475  
-		Deprecation::notice('3.0', 'Use DataObject::get and DataList to do your querying instead.');
  2475
+		Deprecation::notice('3.0', 'Use DataList::create and DataList to do your querying instead.');
2476 2476
 		return $this->extendedSQL($filter, $sort, $limit, $join, $having);
2477 2477
 
2478 2478
 	}
@@ -2483,10 +2483,10 @@ public function buildSQL($filter = "", $sort = "", $limit = "", $join = "", $res
2483 2483
 	private static $cache_buildSQL_query;
2484 2484
 
2485 2485
 	/**
2486  
-	 * @deprecated 3.0 Use DataObject::get and DataList to do your querying
  2486
+	 * @deprecated 3.0 Use DataList::create and DataList to do your querying
2487 2487
 	 */
2488 2488
 	public function extendedSQL($filter = "", $sort = "", $limit = "", $join = ""){
2489  
-		Deprecation::notice('3.0', 'Use DataObject::get and DataList to do your querying instead.');
  2489
+		Deprecation::notice('3.0', 'Use DataList::create and DataList to do your querying instead.');
2490 2490
 		$dataList = DataObject::get($this->class, $filter, $sort, $join, $limit);
2491 2491
 		return $dataList->dataQuery()->query();
2492 2492
 	}
@@ -2521,10 +2521,10 @@ public static function get($callerClass, $filter = "", $sort = "", $join = "", $
2521 2521
 	}
2522 2522
 	
2523 2523
 	/**
2524  
-	 * @deprecated 3.0 Use DataObject::get and DataList to do your querying
  2524
+	 * @deprecated 3.0 Use DataList::create and DataList to do your querying
2525 2525
 	 */
2526 2526
 	public function Aggregate($class = null) {
2527  
-		Deprecation::notice('3.0', 'Use DataObject::get and DataList to do your querying instead.');
  2527
+		Deprecation::notice('3.0', 'Use DataList::create and DataList to do your querying instead.');
2528 2528
 
2529 2529
 	    if($class) {
2530 2530
 			$list = new DataList($class);
@@ -2538,19 +2538,18 @@ public function Aggregate($class = null) {
2538 2538
 	}
2539 2539
 
2540 2540
 	/**
2541  
-	 * @deprecated 3.0 Use DataObject::get and DataList to do your querying
  2541
+	 * @deprecated 3.0 Use DataList::create and DataList to do your querying
2542 2542
 	 */
2543 2543
 	public function RelationshipAggregate($relationship) {
2544  
-		Deprecation::notice('3.0', 'Use DataObject::get and DataList to do your querying instead.');
  2544
+		Deprecation::notice('3.0', 'Use DataList::create and DataList to do your querying instead.');
2545 2545
 
2546 2546
 	    return $this->$relationship();
2547 2547
 	}
2548 2548
 
2549 2549
 	/**
2550  
-	 * The internal function that actually performs the querying for get().
2551  
-	 * DataObject::get("Table","filter") is the same as singleton("Table")->instance_get("filter")
  2550
+	 * DataList::create("Table")->where("filter") is the same as singleton("Table")->instance_get("filter")
2552 2551
 	 *
2553  
-	 * @deprecated 3.0 Use DataObject::get and DataList to do your querying
  2552
+	 * @deprecated 3.0 Use DataList::create and DataList to do your querying
2554 2553
 	 *
2555 2554
 	 * @param string $filter A filter to be inserted into the WHERE clause.
2556 2555
 	 * @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) {
2561 2560
 	 * @return mixed The objects matching the filter, in the class specified by $containerClass
2562 2561
 	 */
2563 2562
 	public function instance_get($filter = "", $sort = "", $join = "", $limit="", $containerClass = "DataObjectSet") {
2564  
-		Deprecation::notice('3.0', 'Use DataObject::get and DataList to do your querying instead.');
  2563
+		Deprecation::notice('3.0', 'Use DataList::create and DataList to do your querying instead.');
2565 2564
 		return self::get($this->class, $filter, $sort, $join, $limit, $containerClass);
2566 2565
 	}
2567 2566
 
@@ -2693,7 +2692,7 @@ static function reset() {
2693 2692
 	/**
2694 2693
 	 * Does the hard work for get_one()
2695 2694
 	 *
2696  
-	 * @deprecated 3.0 Use DataObject::get_one() instead
  2695
+	 * @deprecated 3.0 Use DataList::create($this->class)->where($filter)->sort($orderby)->First() instead
2697 2696
 	 * 
2698 2697
 	 * @uses DataExtension->augmentSQL()
2699 2698
 	 *
@@ -2702,7 +2701,7 @@ static function reset() {
2702 2701
 	 * @return DataObject The first item matching the query
2703 2702
 	 */
2704 2703
 	public function instance_get_one($filter, $orderby = null) {
2705  
-		Deprecation::notice('3.0', 'Use DataObject::get_one() instead.');
  2704
+		Deprecation::notice('3.0', 'Use DataList::create($this->class)->where($filter)->sort($orderby)->First() instead.');
2706 2705
 		return DataObject::get_one($this->class, $filter, true, $orderby);
2707 2706
 	}
2708 2707
 
2  model/DataQuery.php
@@ -145,7 +145,7 @@ function getFinalisedQuery() {
145 145
 			if($this->dataClass != $baseClass) {
146 146
 				// Get the ClassName values to filter to
147 147
 				$classNames = ClassInfo::subclassesFor($this->dataClass);
148  
-				if(!$classNames) user_error("DataObject::get() Can't find data sub-classes for '$callerClass'");
  148
+				if(!$classNames) user_error("DataList::create() Can't find data sub-classes for '$callerClass'");
149 149
 				$query->where[] = "\"$baseClass\".\"ClassName\" IN ('" . implode("','", $classNames) . "')";
150 150
 			}
151 151
 		}
2  model/Versioned.php
@@ -1006,7 +1006,7 @@ function isLatestVersion() {
1006 1006
 	}
1007 1007
 
1008 1008
 	/**
1009  
-	 * Return the equivalent of a DataObject::get() call, querying the latest
  1009
+	 * Return the equivalent of a DataList::create() call, querying the latest
1010 1010
 	 * version of each page stored in the (class)_versions tables.
1011 1011
 	 *
1012 1012
 	 * In particular, this will query deleted records as well as active ones.

0 notes on commit 9e60225

Please sign in to comment.
Something went wrong with that request. Please try again.