EXTMVC:
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Persistence / Mapper / ObjectRelationalMapper.php
index ea57a11..404eeaf 100644 (file)
@@ -215,10 +215,9 @@ class TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper implements t3lib_Singl
         * @return void
         */
        // SK: I need to check this more thorougly
-       protected function insertObject(TX_EXTMVC_DomainObject_AbstractDomainObject $object, $parentObject = NULL, $parentPropertyName = NULL) {
+       protected function insertObject(TX_EXTMVC_DomainObject_AbstractDomainObject $object, $parentObject = NULL, $parentPropertyName = NULL, $recurseIntoRelations = TRUE) {
                $properties = $object->_getProperties();
                $dataMap = $this->getDataMap(get_class($object));
-               $relations = $this->getRelations($dataMap, $properties);
                $row = $this->getRow($dataMap, $properties);
 
                if ($parentObject instanceof TX_EXTMVC_DomainObject_AbstractDomainObject && $parentPropertyName !== NULL) {
@@ -235,6 +234,7 @@ class TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper implements t3lib_Singl
                }
 
                unset($row['uid']);
+
                $row['pid'] = !empty($this->cObj->data['pages']) ? $this->cObj->data['pages'] : $GLOBALS['TSFE']->id;
                $row['tstamp'] = time();
 
@@ -245,10 +245,7 @@ class TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper implements t3lib_Singl
                        );
                $object->_reconstituteProperty('uid', $GLOBALS['TYPO3_DB']->sql_insert_id());
 
-               $recurseIntoRelations = TRUE; // TODO Make this configurable
-               if ($recurseIntoRelations === TRUE) {
-                       $this->persistRelations($object, $propertyName, $relations);
-               }
+               $this->persistRelations($object, $propertyName, $this->getRelations($dataMap, $properties));
        }
 
        /**
@@ -257,12 +254,12 @@ class TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper implements t3lib_Singl
         * @return void
         */
        // SK: I need to check this more thorougly
-       protected function updateObject(TX_EXTMVC_DomainObject_AbstractDomainObject $object, $parentObject = NULL, $parentPropertyName = NULL) {
+       protected function updateObject(TX_EXTMVC_DomainObject_AbstractDomainObject $object, $parentObject = NULL, $parentPropertyName = NULL, $recurseIntoRelations = TRUE) {
                $properties = $object->_getDirtyProperties();
                $dataMap = $this->getDataMap(get_class($object));
-               $relations = $this->getRelations($dataMap, $properties);
                $row = $this->getRow($dataMap, $properties);
                unset($row['uid']);
+               // TODO Check for crdate column
                $row['crdate'] = time();
                if (!empty($GLOBALS['TSFE']->fe_user->user['uid'])) {
                        $row['cruser_id'] = $GLOBALS['TSFE']->fe_user->user['uid'];
@@ -287,10 +284,7 @@ class TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper implements t3lib_Singl
                        $row
                        );
 
-               $recurseIntoRelations = TRUE; // TODO make parametric
-               if ($recurseIntoRelations === TRUE) {
-                       $this->persistRelations($object, $propertyName, $relations);
-               }
+               $this->persistRelations($object, $propertyName, $this->getRelations($dataMap, $properties));
        }
 
        /**
@@ -329,7 +323,7 @@ class TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper implements t3lib_Singl
         * Returns a table row to be inserted or updated in the database
         *
         * @param TX_EXTMVC_Persistence_Mapper_DataMap $dataMap The appropriate data map representing a database table
-        * @param string $properties The properties of the object
+        * @param array $properties The properties of the object
         * @return array A single row to be inserted in the database
         */
        // SK: I need to check this more thorougly
@@ -341,6 +335,7 @@ class TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper implements t3lib_Singl
                        if ($columnMap->getTypeOfRelation() === TX_EXTMVC_Persistence_Mapper_ColumnMap::RELATION_HAS_MANY) {
                                $row[$columnName] = count($properties[$propertyName]);
                        } elseif ($columnMap->getTypeOfRelation() === TX_EXTMVC_Persistence_Mapper_ColumnMap::RELATION_HAS_AND_BELONGS_TO_MANY) {
+                               // TODO Check if this elseif is needed or could be merged with the lines above
                                $row[$columnName] = count($properties[$propertyName]);
                        } else {
                                if ($properties[$propertyName] !== NULL) {