* implemented session as singleton (no setSession() anymore)
authorJochen Rau <j.rau@web.de>
Tue, 27 Jan 2009 10:17:31 +0000 (10:17 +0000)
committerJochen Rau <j.rau@web.de>
Tue, 27 Jan 2009 10:17:31 +0000 (10:17 +0000)
* instanciation of session now in Persistance Repository

typo3/sysext/extbase/Classes/Controller/TX_EXTMVC_Controller_AbstractController.php
typo3/sysext/extbase/Classes/Persistence/TX_EXTMVC_Persistence_Repository.php
typo3/sysext/extbase/Classes/Persistence/TX_EXTMVC_Persistence_Session.php
typo3/sysext/extbase/Classes/TX_EXTMVC_ControllerInterface.php
typo3/sysext/extbase/class.tx_extmvc_dispatcher.php

index 899ecea..95ac95d 100755 (executable)
@@ -48,13 +48,6 @@ abstract class TX_EXTMVC_Controller_AbstractController implements TX_EXTMVC_Cont
         */
        protected $settings;
 
-       /**
-        * Contains the persistence session of the current extension
-        *
-        * @var TX_EXTMVC_Persistence_Session
-        */
-       protected $session;
-
        /**
         * Constructs the controller.
         *
@@ -78,17 +71,6 @@ abstract class TX_EXTMVC_Controller_AbstractController implements TX_EXTMVC_Cont
                $this->settings = $settings;
        }
 
-       /**
-        * Injects the session of the extension.
-        *
-        * @param array $session Persistence session of the current extension
-        * @return void
-        * @author Jochen Rau <jochen.rau@typoplanet.de>
-        */
-       public function injectSession(TX_EXTMVC_Persistence_Session $session) {
-               $this->session = $session;
-       }
-
        /**
         * Initializes this object after all dependencies have been resolved.
         *
index 4c07a1a..fbade1e 100644 (file)
@@ -54,6 +54,8 @@ class TX_EXTMVC_Persistence_Repository implements TX_EXTMVC_Persistence_Reposito
         */
        public function __construct() {
                $this->objects = new TX_EXTMVC_Persistence_ObjectStorage();
+               $this->session = t3lib_div::makeInstance('TX_EXTMVC_Persistence_Session');
+               $this->session->registerRepository(get_class($this));
        }
        
        /**
@@ -97,21 +99,10 @@ class TX_EXTMVC_Persistence_Repository implements TX_EXTMVC_Persistence_Reposito
         * @return void
         * @author Jochen Rau <jochen.rau@typoplanet.de>
         */
-       public function persistAll() {
+       public function persistAll() {          
                if ($this->session->getRemovedObjects()->count() > 0) $this->deleteRemoved();
                if ($this->session->getAddedObjects()->count() > 0) $this->insertAdded();
-               // if ($this->session->getChangedObjects()->count() > 0) $this->updateChanged();
-       }
-       
-       /**
-        * Sets the persistence session
-        * 
-        * @param TX_EXTMVC_Persistence_Session $session The persistence session
-        * @author Jochen Rau <jochen.rau@typoplanet.de>
-        */
-       public function setSession(TX_EXTMVC_Persistence_Session $session) {
-               $session->registerRepository(get_class($this));
-               $this->session = $session;
+               // if ($this->session->getDirtyObjects()->count() > 0) $this->updateDirty();
        }
        
        // TODO implement magic find functions for public properties
index b9cf513..c35dc85 100644 (file)
@@ -21,6 +21,7 @@ declare(ENCODING = 'utf-8');
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
 
+require_once(PATH_t3lib . 'interfaces/interface.t3lib_singleton.php');
 require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/TX_EXTMVC_AbstractDomainObject.php');
 require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Persistence/TX_EXTMVC_Persistence_ObjectStorage.php');
 
@@ -30,7 +31,7 @@ require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Persistence/TX_EXTMVC_Pe
  * @version $Id:$
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class TX_EXTMVC_Persistence_Session {
+class TX_EXTMVC_Persistence_Session implements t3lib_singleton {
 // TODO Implement against SessionInterface
                
        /**
@@ -92,17 +93,6 @@ class TX_EXTMVC_Persistence_Session {
                $this->addedObjects->attach($object);
        }
 
-       /**
-        * Unegisters an added object
-        *
-        * @param TX_EXTMVC_AbstractDomainObject $object
-        * @return void
-        * @author Jochen Rau <jochen.rau@typoplanet.de>
-        */
-       public function unregisterAddedObject(TX_EXTMVC_AbstractDomainObject $object) {
-               $this->addedObjects->detach($object);
-       }
-       
        /**
         * Returns all objects which have been registered as added objects
         *
@@ -128,17 +118,6 @@ class TX_EXTMVC_Persistence_Session {
                }
        }
 
-       /**
-        * Unegisters a removed object
-        *
-        * @param TX_EXTMVC_AbstractDomainObject $object
-        * @return void
-        * @author Jochen Rau <jochen.rau@typoplanet.de>
-        */
-       public function unregisterRemovedObject(TX_EXTMVC_AbstractDomainObject $object) {
-               $this->removedObjects->detach($object);
-       }
-       
        /**
         * Returns all objects which have been registered as removed objects
         *
@@ -161,17 +140,6 @@ class TX_EXTMVC_Persistence_Session {
                $this->memorizeCleanObjectState($object);
        }
 
-       /**
-        * Unregisters a reconstituted object
-        *
-        * @param TX_EXTMVC_AbstractDomainObject $object
-        * @return void
-        * @author Jochen Rau <jochen.rau@typoplanet.de>
-        */
-       public function unregisterReconstitutedObject(TX_EXTMVC_AbstractDomainObject $object) {
-               $this->reconstitutedObjects->detach($object);
-       }
-
        /**
         * Returns all objects which have been registered as reconstituted objects
         *
@@ -193,7 +161,7 @@ class TX_EXTMVC_Persistence_Session {
                $this->cleanObjects->attach(clone($object));
        }
 
-       public function getChangedObjects() {
+       public function getDirtyObjects() {
                // return NULL;
        }       
        
index 5038a26..71836f6 100644 (file)
@@ -37,14 +37,5 @@ interface TX_EXTMVC_ControllerInterface {
         */
        public function injectSettings(array $settings);
        
-       /**
-        * Injects the session of the extension.
-        *
-        * @param array $session Persistence session of the current extension
-        * @return void
-        * @author Jochen Rau <jochen.rau@typoplanet.de>
-        */
-       public function injectSession(TX_EXTMVC_Persistence_Session $session);
-
 }
 ?>
\ No newline at end of file
index 390dfdc..cf8fddc 100644 (file)
@@ -108,7 +108,6 @@ class TX_EXTMVC_Dispatcher {
                // $settings = $this->configurationManager->getSettings($extensionKey);
                // $controller->injectSettings($this->configurationManager->getSettings($request->getControllerExtensionKey()));
                $session = t3lib_div::makeInstance('TX_EXTMVC_Persistence_Session');
-               $controller->injectSession($session);
                $controller->processRequest($request, $response);               
                $session->commit();
                $session->clear();