Permalink
Browse files

API CHANGE Renamed setModel for DataModel instances to setDataModel for

semantics, and also to allow a field name called "Model"
  • Loading branch information...
1 parent befc806 commit 0882741f549ecd526c2a432b1c68918c1701ccd5 @halkyon halkyon committed May 1, 2012
@@ -12,7 +12,7 @@ class VersionedRestfulServer extends Controller {
);
function handleRequest(SS_HTTPRequest $request, DataModel $model) {
- $this->setModel($model);
+ $this->setDataModel($model);
Versioned::reading_stage('Live');
$restfulserver = new RestfulServer();
$response = $restfulserver->handleRequest($request, $model);
View
@@ -129,7 +129,7 @@ function handleRequest(SS_HTTPRequest $request, DataModel $model) {
$this->urlParams = $request->allParams();
$this->request = $request;
$this->response = new SS_HTTPResponse();
- $this->setModel($model);
+ $this->setDataModel($model);
$this->extend('onBeforeInit');
@@ -91,7 +91,7 @@ public function __construct() {
// Check necessary to avoid class conflicts before manifest is rebuilt
if(class_exists('NullHTTPRequest')) $this->request = new NullHTTPRequest();
- // This will prevent bugs if setModel() isn't called.
+ // This will prevent bugs if setDataModel() isn't called.
$this->model = DataModel::inst();
parent::__construct();
@@ -100,7 +100,7 @@ public function __construct() {
/**
* Set the DataModel for this request.
*/
- public function setModel($model) {
+ public function setDataModel($model) {
$this->model = $model;
}
@@ -134,7 +134,7 @@ function handleRequest(SS_HTTPRequest $request, DataModel $model) {
}
$this->request = $request;
- $this->setModel($model);
+ $this->setDataModel($model);
// We stop after RequestHandler; in other words, at ViewableData
while($handlerClass && $handlerClass != 'ViewableData') {
@@ -586,7 +586,7 @@ function handleRequest(SS_HTTPRequest $request, DataModel $model) {
}
$this->request = $request;
- $this->setModel($model);
+ $this->setDataModel($model);
$fieldData = $this->request->requestVar($this->getName());
if($fieldData && $fieldData['GridState']) $this->getState(false)->setValue($fieldData['GridState']);
View
@@ -46,7 +46,7 @@ public function __construct($dataClass) {
*
* @param DataModel $model
*/
- public function setModel(DataModel $model) {
+ public function setDataModel(DataModel $model) {
$this->model = $model;
}
View
@@ -35,14 +35,14 @@ function __get($class) {
return clone $this->customDataLists[$class];
} else {
$list = DataList::create($class);
- $list->setModel($this);
+ $list->setDataModel($this);
return $list;
}
}
function __set($class, $item) {
$item = clone $item;
- $item->setModel($this);
+ $item->setDataModel($this);
$this->customDataLists[$class] = $item;
}
View
@@ -399,7 +399,7 @@ function __construct($record = null, $isSingleton = false, $model = null) {
/**
* Set the DataModel
*/
- function setModel(DataModel $model) {
+ function setDataModel(DataModel $model) {
$this->model = $model;
}
@@ -1328,7 +1328,7 @@ public function getComponents($componentName, $filter = "", $sort = "", $join =
$joinField = $this->getRemoteJoinField($componentName, 'has_many');
$result = new HasManyList($componentClass, $joinField);
- if($this->model) $result->setModel($this->model);
+ if($this->model) $result->setDataModel($this->model);
$result->setForeignID($this->ID);
$result = $result->where($filter)->limit($limit)->sort($sort);
@@ -1449,7 +1449,7 @@ public function getManyManyComponents($componentName, $filter = "", $sort = "",
$result = new ManyManyList($componentClass, $table, $componentField, $parentField,
$this->many_many_extraFields($componentName));
- if($this->model) $result->setModel($this->model);
+ if($this->model) $result->setDataModel($this->model);
// If this is called on a singleton, then we return an 'orphaned relation' that can have the
// foreignID set elsewhere.
@@ -2626,7 +2626,7 @@ public static function get($callerClass = null, $filter = "", $sort = "", $join
}
$result = DataList::create(get_called_class());
- $result->setModel(DataModel::inst());
+ $result->setDataModel(DataModel::inst());
return $result;
}
@@ -2641,7 +2641,7 @@ public static function get($callerClass = null, $filter = "", $sort = "", $join
$result->limit($limit);
}
if($join) $result = $result->join($join);
- $result->setModel(DataModel::inst());
+ $result->setDataModel(DataModel::inst());
return $result;
}
@@ -2653,10 +2653,10 @@ public function Aggregate($class = null) {
if($class) {
$list = new DataList($class);
- $list->setModel(DataModel::inst());
+ $list->setDataModel(DataModel::inst());
} else if(isset($this)) {
$list = new DataList(get_class($this));
- $list->setModel($this->model);
+ $list->setDataModel($this->model);
}
else throw new InvalidArgumentException("DataObject::aggregate() must be called as an instance method or passed a classname");
return $list;
@@ -2752,7 +2752,7 @@ public static function get_one($callerClass, $filter = "", $cache = true, $order
}
if(!$cache || !isset(DataObject::$_cache_get_one[$callerClass][$cacheKey])) {
$dl = DataList::create($callerClass)->where($filter)->sort($orderby);
- $dl->setModel(DataModel::inst());
+ $dl->setDataModel(DataModel::inst());
$item = $dl->First();
if($cache) {
View
@@ -341,7 +341,7 @@ public function login() {
$tmpPage->ID = -1 * rand(1,10000000);
$controller = new Page_Controller($tmpPage);
- $controller->setModel($this->model);
+ $controller->setDataModel($this->model);
$controller->init();
//Controller::$currentController = $controller;
} else {
@@ -1222,17 +1222,15 @@ class DataObjectTest_CEO extends DataObjectTest_Staff {
}
class DataObjectTest_TeamComment extends DataObject {
-
static $db = array(
- 'Name' => "Varchar",
- "Comment" => "Text"
+ 'Name' => 'Varchar',
+ 'Comment' => 'Text'
);
-
+
static $has_one = array(
- 'Team' => 'DataObjectTest_Team'
+ 'Team' => 'DataObjectTest_Team'
);
}
DataObject::add_extension('DataObjectTest_Team', 'DataObjectTest_Team_Extension');
-

0 comments on commit 0882741

Please sign in to comment.