Extbase:
authorSebastian Kurfürst <sebastian@typo3.org>
Sat, 11 Jul 2009 16:32:01 +0000 (16:32 +0000)
committerSebastian Kurfürst <sebastian@typo3.org>
Sat, 11 Jul 2009 16:32:01 +0000 (16:32 +0000)
* Reviewed code
* Biggest issue: Objects must be registered manually as reconstituted in the Persistence Session. I think this should be done by the data mapper.
* I still need to understand JOINs and relations fully.

typo3/sysext/extbase/Classes/Persistence/Backend.php
typo3/sysext/extbase/Classes/Persistence/DataMapperInterface.php
typo3/sysext/extbase/Classes/Persistence/Mapper/DataMap.php
typo3/sysext/extbase/Classes/Persistence/Mapper/DataMapper.php
typo3/sysext/extbase/Classes/Persistence/PreparedQuery.php
typo3/sysext/extbase/Classes/Persistence/PreparedQueryInterface.php
typo3/sysext/extbase/Classes/Persistence/PropertyType.php
typo3/sysext/extbase/Classes/Persistence/Repository.php
typo3/sysext/extbase/Classes/Persistence/Session.php

index 66218c6..a04358d 100644 (file)
@@ -279,7 +279,7 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
                        $this->checkForAlreadyPersistedValueObject($object);
                }
 
-
+               // Fill up $row[$columnName] array with changed values which need to be stored
                foreach ($properties as $propertyName => $propertyValue) {
                        if ($dataMap->isPersistableProperty($propertyName) && ($propertyValue instanceof Tx_Extbase_Persistence_LazyLoadingProxy)) {
                                continue;
@@ -296,12 +296,16 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
                                                }
                                        } elseif ($propertyValue instanceof Tx_Extbase_DomainObject_DomainObjectInterface) {
                                                // TODO Handle Value Objects different
+                                               // SK: this is the case RELATION_HAS_ONE, correct?
                                                if ($propertyValue->_isNew()) {
+                                                       // SK: What happens if the value is not new, but changed?
                                                        $this->persistObject($propertyValue);
                                                }
                                                $row[$columnName] = $propertyValue->getUid();
                                        }
                                } else {
+                                       // Not an relation, this means it is a simple type such as STRING or Integer
+                                       // SK: I think that the second option $fullQuoteString is NOT needed here, as this should be the job of the persistence backend.
                                        $row[$columnName] = $dataMap->convertPropertyValueToFieldValue($properties[$propertyName], FALSE);
                                }
                        }
@@ -312,7 +316,8 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
                } elseif ($object->_isDirty()) {
                                $this->updateObject($object, $parentObject, $parentPropertyName, $row);
                }
-
+               
+               // SK: I need to check the code below more thoroughly
                if ($parentObject instanceof Tx_Extbase_DomainObject_DomainObjectInterface && !empty($parentPropertyName)) {
                        $parentClassName = get_class($parentObject);
                        $parentDataMap = $this->dataMapper->getDataMap($parentClassName);
@@ -326,7 +331,8 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
                if ($object instanceof Tx_Extbase_DomainObject_AbstractEntity) {
                        $object->_memorizeCleanState();
                }
-
+               
+               // SK: Where does $queue come from? Do we need the code below?
                if ($processQueue === TRUE) {
                        foreach ($queue as $queuedObjects) {
                                foreach($queuedObjects as $propertyName => $queuedObject) {
@@ -536,6 +542,9 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
         * @param array $relations The queued relations
         * @return void
         */
+       // SK: The below method is never called.
+       // SK: I think there is still a problem with deleted objects and deleted relations.
+       // SK: I am not yet sure where deleted relations ae handled. Need to check more thoroughly!
        protected function deleteRelatedObjects(Tx_Extbase_DomainObject_DomainObjectInterface $object, array $relations) {
                $dataMap = $this->dataMapper->getDataMap(get_class($object));
                foreach ($relations as $propertyName => $relatedObjects) {
index 083c03c..680abfd 100644 (file)
@@ -29,6 +29,7 @@
  * @subpackage extbase
  * @version $ID:$
  */
+// SK: Is this interface used anywhere? I guess not.
 interface Tx_Extbase_Persistence_DataMapperInterface {
 
        /**
index 28809c4..707b6dc 100644 (file)
@@ -121,7 +121,7 @@ class Tx_Extbase_Persistence_Mapper_DataMap {
                                $this->setPropertyType($columnMap, $columnConfiguration);
                                // TODO support for IRRE
                                // TODO support for MM_insert_fields and MM_match_fields
-                               // SK: Discuss the above things
+                               // SK: are the above TODOs still valid?
                                $this->setRelations($columnMap, $columnConfiguration);
                                $this->addColumnMap($columnMap);
                        }
index faa090f..34e869e 100644 (file)
@@ -183,11 +183,14 @@ class Tx_Extbase_Persistence_Mapper_DataMapper implements t3lib_Singleton {
                                break;
                                        // FIXME we have an object to handle... -> exception
                                default:
+                                       // SK: We should throw an exception as this point as there was an undefined propertyType we can not handle.
                                        if (isset($row[$propertyName])) {
                                                $property = $row[$propertyName];
                                                if (is_object($property)) {
                                                        $propertyValue = $this->mapObject($property);
+                                                       // SK: THIS case can not happen I think. At least $this->mapObject() is not available.
                                                } else {
+                                                       // SK: This case does not make sense either. $this-mapSingleRow has a different signature 
                                                        $propertyValue = $this->mapSingleRow($className, $property);
                                                }
                                        }
index d479cab..d2b1dcf 100644 (file)
@@ -34,6 +34,7 @@
  * @version $Id: PreparedQuery.php 2120 2009-04-02 10:06:31Z k-fish $
  * @scope prototype
  */
+// SK: I think this can be removed for now.
 class Tx_Extbase_Persistence_PreparedQuery extends Tx_Extbase_Persistence_Query implements Tx_Extbase_Persistence_PreparedQueryInterface {
 
        /**
index e7934f4..e683809 100644 (file)
@@ -33,6 +33,7 @@
  * @subpackage Persistence
  * @version $Id: PreparedQueryInterface.php 1811 2009-01-28 12:04:49Z robert $
  */
+// SK: I think this can be removed for now.
 interface Tx_Extbase_Persistence_PreparedQueryInterface extends Tx_Extbase_Persistence_QueryInterface {
 
        /**
index 362428b..0368502 100644 (file)
@@ -89,6 +89,8 @@ final class Tx_Extbase_Persistence_PropertyType {
        /**
         * A NAME is a pairing of a namespace and a local name. When read, the
         * namespace is mapped to the current prefix.
+        * 
+        * WE DO NOT USE THIS IN EXTBASE!
         */
        const NAME = 7;
 
@@ -96,6 +98,8 @@ final class Tx_Extbase_Persistence_PropertyType {
         * A PATH property is an ordered list of path elements. A path element is a
         * NAME with an optional index. When read, the NAMEs within the path are
         * mapped to their current prefix. A path may be absolute or relative.
+        * 
+        * WE DO NOT USE THIS IN EXTBASE!
         */
        const PATH = 8;
 
@@ -112,6 +116,8 @@ final class Tx_Extbase_Persistence_PropertyType {
         * A WEAKREFERENCE property stores the identifier of a referenceable node
         * (one having type mix:referenceable). A WEAKREFERENCE property does not
         * enforce referential integrity.
+        * 
+        * WE DO NOT USE THIS IN EXTBASE!
         */
        const WEAKREFERENCE = 10;
 
@@ -119,16 +125,22 @@ final class Tx_Extbase_Persistence_PropertyType {
         * A URI property is identical to STRING property except that it only
         * accepts values that conform to the syntax of a URI-reference as defined
         * in RFC 3986.
+        *
+        * WE DO NOT USE THIS IN EXTBASE!
         */
        const URI = 11;
 
        /**
         * The DECIMAL property type is used to store precise decimal numbers.
+        * 
+        * WE DO NOT USE THIS IN EXTBASE!
         */
        const DECIMAL = 12;
 
        /**
         * The INTEGER property type is used to store precise decimal numbers.
+        * 
+        * WE DO NOT USE THIS IN EXTBASE!
         */
        const INTEGER = 13;
 
index 837c81a..cd7d7a6 100644 (file)
@@ -176,6 +176,7 @@ class Tx_Extbase_Persistence_Repository implements Tx_Extbase_Persistence_Reposi
                        $object = NULL;
                        if (count($result) > 0) {
                                $object = current($result);
+                               // SK: registerReconstitutedObject() needs to be called automatically inside the DataMapper!
                                $this->persistenceManager->getSession()->registerReconstitutedObject($object);
                        }
                        return $object;
index ffb9b7d..e497d82 100644 (file)
@@ -286,6 +286,7 @@ class Tx_Extbase_Persistence_Session implements t3lib_singleton {
         * @return void
         */
        public function commit() {
+               // SK: This is old code, which needs to be removed.
                $aggregateRootObjects = new Tx_Extbase_Persistence_ObjectStorage();
                $aggregateRootObjects->addAll($this->getAddedObjects());
                $aggregateRootObjects->addAll($this->getReconstitutedObjects());