diff --git a/model/DataObject.php b/model/DataObject.php index 8b0a817ae..afa4e4dfd 100644 --- a/model/DataObject.php +++ b/model/DataObject.php @@ -395,9 +395,12 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity /** * Set the DataModel + * @param DataModel $model + * @return DataObject $this */ public function setDataModel(DataModel $model) { $this->model = $model; + return $this; } /** @@ -503,6 +506,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * or destroy and reinstanciate the record. * * @param string $className The new ClassName attribute (a subclass of {@link DataObject}) + * @return DataObject $this */ public function setClassName($className) { $className = trim($className); @@ -510,6 +514,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity $this->class = $className; $this->setField("ClassName", $className); + return $this; } /** @@ -745,6 +750,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * the related objects that it alters. * * @param array $data A map of field name to data values to update. + * @return DataObject $this */ public function update($data) { foreach($data as $k => $v) { @@ -784,6 +790,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity $this->$k = $v; } } + return $this; } /** @@ -793,11 +800,13 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * use the write() method. * * @param array $data A map of field name to data values to update. + * @return DataObject $this */ public function castedUpdate($data) { foreach($data as $k => $v) { $this->setCastedField($k,$v); } + return $this; } /** @@ -895,6 +904,8 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * Forces the record to think that all its data has changed. * Doesn't write to the database. Only sets fields as changed * if they are not already marked as changed. + * + * @return DataObject $this */ public function forceChange() { // Ensure lazy fields loaded @@ -913,6 +924,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity // @todo Find better way to allow versioned to write a new version after forceChange if($this->isChanged('Version')) unset($this->changed['Version']); + return $this; } /** @@ -987,7 +999,8 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * Will traverse the defaults of the current class and all its parent classes. * Called by the constructor when creating new records. * - * @uses DataExtension->populateDefaults() + * @uses DataExtension->populateDefaults() + * @return DataObject $this */ public function populateDefaults() { $classes = array_reverse(ClassInfo::ancestry($this)); @@ -1018,6 +1031,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity } $this->extend('populateDefaults'); + return $this; } /** @@ -1235,13 +1249,15 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * same record. * * @param $recursive Recursively write components + * @return DataObject $this */ public function writeComponents($recursive = false) { - if(!$this->components) return; + if(!$this->components) return $this; foreach($this->components as $component) { $component->write(false, false, false, $recursive); } + return $this; } /** @@ -2230,6 +2246,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * * @param string $fieldName Name of the field * @param mixed $val New field value + * @return DataObject $this */ public function setField($fieldName, $val) { // Situation 1: Passing an DBField @@ -2273,6 +2290,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity $this->record[$fieldName] = $val; } } + return $this; } /** @@ -2283,6 +2301,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * * @param string $fieldName Name of the field * @param mixed $value New field value + * @return DataObject $this */ public function setCastedField($fieldName, $val) { if(!$fieldName) { @@ -2296,6 +2315,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity } else { $this->$fieldName = $val; } + return $this; } /** @@ -2832,14 +2852,14 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity * * @param boolean $persistent When true will also clear persistent data stored in the Cache system. * When false will just clear session-local cached data - * + * @return DataObject $this */ public function flushCache($persistent = true) { if($persistent) Aggregate::flushCache($this->class); if($this->class == 'DataObject') { DataObject::$_cache_get_one = array(); - return; + return $this; } $classes = ClassInfo::ancestry($this->class); @@ -2850,6 +2870,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity $this->extend('flushCache'); $this->components = array(); + return $this; } /**