***************************************************************/
/**
- * A generic Domain Object
+ * A generic Domain Object.
+ *
+ * All Model domain objects need to inherit from either AbstractEntity or AbstractValueObject, as this provides important framework information.
*
* @package Extbase
- * @subpackage extbase
+ * @subpackage DomainObject
* @version $ID:$
*/
abstract class Tx_Extbase_DomainObject_AbstractDomainObject implements Tx_Extbase_DomainObject_DomainObjectInterface {
/**
- * @var string The uid
+ * @var int The uid
*/
protected $uid;
+ /**
+ * @var int The uid of the localization parent
+ */
+ protected $_localizationParentUid;
+
+ /**
+ * TRUE if the object is a clone
+ * @var boolean
+ */
+ private $_isClone = FALSE;
+
/**
* The generic constructor. If you want to implement your own __constructor() method in your Domain Object you have to call
* $this->initializeObject() in the first line of your constructor.
* parent::__wakeup() first!
*
* @return void
- * @internal
*/
public function __wakeup() {
- foreach ($GLOBALS['Extbase']['reconstituteObject']['properties'] as $propertyName => $propertyValue) {
- $this->_reconstituteProperty($propertyName, $propertyValue);
- }
$this->initializeObject();
}
}
/**
- * Getter for uid
+ * Getter for uid.
*
- * @return string
+ * @return int the uid or NULL if none set yet.
*/
final public function getUid() {
- return $this->uid;
+ if ($this->uid !== NULL) {
+ return (int)$this->uid;
+ } else {
+ return NULL;
+ }
}
-
+
/**
- * Reconstitutes a property. This method should only be called at reconstitution time by the framework!
+ * Reconstitutes a property. Only for internal use.
*
* @param string $propertyName
* @param string $value
* @return void
- * @internal
*/
- public function _reconstituteProperty($propertyName, $value) {
- if (property_exists($this, $propertyName)) {
- $this->$propertyName = $value;
+ public function _setProperty($propertyName, $propertyValue) {
+ if ($this->_hasProperty($propertyName)) {
+ $this->$propertyName = $propertyValue;
return TRUE;
}
return FALSE;
}
+ /**
+ * Returns the property value of the given property name. Only for internal use.
+ *
+ * @return mixed The propertyValue
+ */
+ public function _getProperty($propertyName) {
+ return $this->$propertyName;
+ }
+
/**
* Returns a hash map of property names and property values. Only for internal use.
*
* @return array The properties
- * @internal
*/
public function _getProperties() {
$properties = get_object_vars($this);
- // unset($properties['_cleanProperties']); // TODO Check this again
+ foreach ($properties as $propertyName => $propertyValue) {
+ if ($propertyName{0} === '_') {
+ unset($properties[$propertyName]);
+ }
+ }
return $properties;
}
-
+
/**
* Returns the property value of the given property name. Only for internal use.
*
- * @return array The propertyName
- * @internal
+ * @return boolean TRUE bool true if the property exists, FALSE if it doesn't exist or
+ * NULL in case of an error.
*/
- public function _getPropertyValue($propertyName) {
- return $this->$propertyName;
+ public function _hasProperty($propertyName) {
+ return property_exists($this, $propertyName);
}
/**
* Returns TRUE if the object is new (the uid was not set, yet). Only for internal use
*
* @return boolean
- * @internal
*/
public function _isNew() {
return $this->uid === NULL;
* from the database
*
* @return void
- * @internal
*/
public function _memorizeCleanState() {
}
+
+ /**
+ * Returns TRUE if the properties were modified after reconstitution. However, value objects can be never updated.
+ *
+ * @return boolean
+ */
+ public function _isDirty($propertyName = NULL) {
+ return FALSE;
+ }
/**
- * Returns a hash map of dirty properties and $values. This is always the empty array for ValueObjects, because ValueObjects never change.
+ * Returns TRUE if the object has been clonesd, cloned, FALSE otherwise.
*
- * @return array
- * @internal
+ * @return boolean TRUE if the object has been cloned
*/
- public function _getDirtyProperties() {
- return array();
+ public function _isClone() {
+ return $this->_isClone;
}
/**
- * Returns TRUE if the properties were modified after reconstitution. However, value objects can be never updated.
+ * Setter whether this Domain Object is a clone of another one.
+ * NEVER SET THIS PROPERTY DIRECTLY. We currently need it to make the
+ * _isDirty check inside AbstractEntity work, but it is just a work-
+ * around right now.
*
- * @return boolean
- * @internal
+ * @param boolean $clone
*/
- public function _isDirty() {
- return FALSE;
+ public function _setClone($clone) {
+ $this->_isClone = (boolean)$clone;
+ }
+
+ /**
+ * Clone method. Sets the _isClone property.
+ *
+ * @return void
+ */
+ public function __clone() {
+ $this->_isClone = TRUE;
}
+
}
?>
\ No newline at end of file