[+BUGFIX] Extbase (MVC): Fixed instanciation of Reflection Service (instanciated...
authorJochen Rau <j.rau@web.de>
Thu, 17 Sep 2009 07:23:38 +0000 (07:23 +0000)
committerJochen Rau <j.rau@web.de>
Thu, 17 Sep 2009 07:23:38 +0000 (07:23 +0000)
[+BUGFIX] Extbase (Persistence): Fixed wrong variable name ($uid -> $identifier).
[+TASK] Extbase (Persistence): Implemented a first level cache to reduce number of calls to the storage backend (in the Repository).
[+TASK] Extbase: Minor cleanups.

typo3/sysext/extbase/Classes/MVC/Controller/Argument.php
typo3/sysext/extbase/Classes/Persistence/Backend.php
typo3/sysext/extbase/Classes/Persistence/Repository.php
typo3/sysext/extbase/ext_emconf.php

index 0b63039..2149d58 100644 (file)
@@ -121,7 +121,7 @@ class Tx_Extbase_MVC_Controller_Argument {
        public function __construct($name, $dataType = 'Text') {
                $this->reflectionService = t3lib_div::makeInstance('Tx_Extbase_Reflection_Service');
                $this->propertyMapper = t3lib_div::makeInstance('Tx_Extbase_Property_Mapper');
-               $this->propertyMapper->injectReflectionService(t3lib_div::makeInstance('Tx_Extbase_Reflection_Service'));
+               $this->propertyMapper->injectReflectionService($this->reflectionService);
                if (!is_string($name) || strlen($name) < 1) throw new InvalidArgumentException('$name must be of type string, ' . gettype($name) . ' given.', 1187951688);
                $this->name = $name;
                $this->setDataType($dataType);
index 1fb1bd0..ceb66fb 100644 (file)
@@ -217,12 +217,12 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
                        return $this->identityMap->getObjectByIdentifier($identifier, $className);
                } else {
                        $query = $this->queryFactory->create($className);
-                       $result = $query->matching($query->withUid($uid))->execute();
+                       $result = $query->matching($query->withUid($identifier))->execute();
                        $object = NULL;
                        if (count($result) > 0) {
                                $object = current($result);
                        }
-                       return $object;                 
+                       return $object;
                }
        }
 
@@ -656,4 +656,4 @@ class Tx_Extbase_Persistence_Backend implements Tx_Extbase_Persistence_BackendIn
 
 }
 
-?>
+?>
\ No newline at end of file
index 601e3d5..e8d6096 100644 (file)
 class Tx_Extbase_Persistence_Repository implements Tx_Extbase_Persistence_RepositoryInterface, t3lib_Singleton {
 
        /**
+        * @var Tx_Extbase_Persistence_IdentityMap
+        **/
+       protected $identityMap;
+
+       /**
         * Objects of this repository
         *
         * @var Tx_Extbase_Persistence_ObjectStorage
@@ -68,6 +73,7 @@ class Tx_Extbase_Persistence_Repository implements Tx_Extbase_Persistence_Reposi
         *
         */
        public function __construct() {
+               $this->identityMap = t3lib_div::makeInstance('Tx_Extbase_Persistence_IdentityMap');
                $this->addedObjects = new Tx_Extbase_Persistence_ObjectStorage();
                $this->removedObjects = new Tx_Extbase_Persistence_ObjectStorage();
                $this->queryFactory = t3lib_div::makeInstance('Tx_Extbase_Persistence_QueryFactory'); // singleton
@@ -211,11 +217,16 @@ class Tx_Extbase_Persistence_Repository implements Tx_Extbase_Persistence_Reposi
         */
        public function findByUid($uid) {
                if (!is_int($uid) || $uid < 0) throw new InvalidArgumentException('The uid must be a positive integer', 1245071889);
-               $query = $this->createQuery();
-               $result = $query->matching($query->withUid($uid))->execute();
-               $object = NULL;
-               if (count($result) > 0) {
-                       $object = current($result);
+               if ($this->identityMap->hasIdentifier($uid, $this->objectType)) {
+                       $object = $this->identityMap->getObjectByIdentifier($uid, $this->objectType);
+               } else {
+                       $query = $this->createQuery();
+                       $result = $query->matching($query->withUid($uid))->execute();
+                       $object = NULL;
+                       if (count($result) > 0) {
+                               $object = current($result);
+                       }
+                       $this->identityMap->registerObject($object, $uid);
                }
                return $object;
        }
index 44d4117..22a24a6 100644 (file)
@@ -14,8 +14,8 @@ $EM_CONF[$_EXTKEY] = array(
        'title' => 'A Framework for Extensions',
        'description' => 'A framework to build extensions in the style of FLOW3 by now.',
        'category' => 'fe',
-       'author' => 'Jochen Rau',
-       'author_email' => 'jochen.rau@typoplanet.de',
+       'author' => '',
+       'author_email' => '',
        'shy' => '',
        'dependencies' => '',
        'conflicts' => '',