Skip to content
This repository
Browse code

MINOR If $containerClass passed in to DataObject::get() isn't DataList,

use Deprecation::notice() instead of throwing a notice
  • Loading branch information...
commit 862d7f249b2b9222cedf5ab44cb4bf16a0ef7af8 1 parent ed1373d
Sean Harvey authored May 28, 2012

Showing 1 changed file with 11 additions and 5 deletions. Show diff stats Hide diff stats

  1. 16  model/DataObject.php
16  model/DataObject.php
@@ -2618,15 +2618,15 @@ public function extendedSQL($filter = "", $sort = "", $limit = "", $join = ""){
2618 2618
 	 *
2619 2619
 	 * @return mixed The objects matching the filter, in the class specified by $containerClass
2620 2620
 	 */
2621  
-	public static function get($callerClass = null, $filter = "", $sort = "", $join = "", $limit = null, $containerClass = "DataList") {
  2621
+	public static function get($callerClass = null, $filter = "", $sort = "", $join = "", $limit = null, $containerClass = 'DataList') {
2622 2622
 		if($callerClass == null) {
2623 2623
 			$callerClass = get_called_class();
2624 2624
 			if($callerClass == 'DataObject') {
2625  
-				throw new \InvalidArgumentException("Call <classname>::get() instead of DataObject::get()");
  2625
+				throw new \InvalidArgumentException('Call <classname>::get() instead of DataObject::get()');
2626 2626
 			}
2627 2627
 			
2628  
-			if($filter || $sort || $join || $limit || ($containerClass != "DataList")) {
2629  
-				throw new \InvalidArgumentException("If calling <classname>::get() then you shouldn't pass any other arguments");
  2628
+			if($filter || $sort || $join || $limit || ($containerClass != 'DataList')) {
  2629
+				throw new \InvalidArgumentException('If calling <classname>::get() then you shouldn\'t pass any other arguments');
2630 2630
 			}
2631 2631
 			
2632 2632
 			$result = DataList::create(get_called_class());
@@ -2636,15 +2636,21 @@ public static function get($callerClass = null, $filter = "", $sort = "", $join
2636 2636
 		
2637 2637
 		// Todo: Determine if we can deprecate for 3.0.0 and use DI or something instead
2638 2638
 		// Todo: Make the $containerClass method redundant
2639  
-		if($containerClass != "DataList") user_error("The DataObject::get() \$containerClass argument has been deprecated", E_USER_NOTICE);
  2639
+		if($containerClass != 'DataList') {
  2640
+			Deprecation::notice('3.0', '$containerClass argument is deprecated.');
  2641
+		}
  2642
+
2640 2643
 		$result = DataList::create($callerClass)->where($filter)->sort($sort);
  2644
+
2641 2645
 		if($limit && strpos($limit, ',') !== false) {
2642 2646
 			$limitArguments = explode(',', $limit);
2643 2647
 			$result->limit($limitArguments[1],$limitArguments[0]);
2644 2648
 		} elseif($limit) {
2645 2649
 			$result->limit($limit);
2646 2650
 		}
  2651
+
2647 2652
 		if($join) $result = $result->join($join);
  2653
+
2648 2654
 		$result->setDataModel(DataModel::inst());
2649 2655
 		return $result;
2650 2656
 	}

0 notes on commit 862d7f2

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