Extbase:
authorJochen Rau <j.rau@web.de>
Tue, 14 Jul 2009 12:27:21 +0000 (12:27 +0000)
committerJochen Rau <j.rau@web.de>
Tue, 14 Jul 2009 12:27:21 +0000 (12:27 +0000)
* The Persistence Backend will now be injected via setter injection rather than via constructor injection. The Persistence Manager can be reached at any "place" via t3lib_div::makeInstance('Tx_Extbase_Persistence_Manager') after its first initialization (in the Dispatcher).

typo3/sysext/extbase/Classes/Dispatcher.php
typo3/sysext/extbase/Classes/MVC/Controller/AbstractController.php
typo3/sysext/extbase/Classes/Persistence/Manager.php
typo3/sysext/extbase/Classes/Persistence/QueryFactory.php
typo3/sysext/extbase/Classes/Persistence/Repository.php

index 6efdbed..695270e 100644 (file)
@@ -70,7 +70,8 @@ class Tx_Extbase_Dispatcher {
                $persistenceBackend->injectQOMFactory(t3lib_div::makeInstance('Tx_Extbase_Persistence_QOM_QueryObjectModelFactory', $storageBackend, $dataMapper));
                $persistenceBackend->injectValueFactory(t3lib_div::makeInstance('Tx_Extbase_Persistence_ValueFactory'));
 
-               $persistenceManager = t3lib_div::makeInstance('Tx_Extbase_Persistence_Manager', $persistenceBackend); // singleton
+               $persistenceManager = t3lib_div::makeInstance('Tx_Extbase_Persistence_Manager'); // singleton
+               $persistenceManager->injectBackend($persistenceBackend);
                $persistenceManager->injectSession($persistenceSession);
 
                $dispatchLoopCount = 0;
index 88a6f3d..3980da6 100755 (executable)
@@ -101,7 +101,7 @@ abstract class Tx_Extbase_MVC_Controller_AbstractController implements Tx_Extbas
        public function __construct() {
                $this->objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_Manager');
                $this->arguments = t3lib_div::makeInstance('Tx_Extbase_MVC_Controller_Arguments');
-               $this->arguments->injectPersistenceManager(t3lib_div::makeInstance('Tx_Extbase_Persistence_Manager'));
+               $this->arguments->injectPersistenceManager(t3lib_div::makeInstance('Tx_Extbase_Persistence_Manager')); // singleton; must have been initialized before
                $this->arguments->injectQueryFactory(t3lib_div::makeInstance('Tx_Extbase_Persistence_QueryFactory'));
                list(, $this->extensionName) = explode('_', get_class($this));
        }
index e74ac40..554f5f4 100644 (file)
@@ -51,16 +51,17 @@ class Tx_Extbase_Persistence_Manager implements Tx_Extbase_Persistence_ManagerIn
        protected $dataMapper;
 
        /**
-        * Constructor
+        * Injects the persistence backend
         *
-        * @param Tx_Extbase_Persistence_BackendInterface $backend the backend to use for persistence
+        * @param Tx_Extbase_Persistence_BackendInterface $backend The persistence backend
+        * @return void
         * @internal
         */
-       public function __construct(Tx_Extbase_Persistence_BackendInterface $backend) {
+       public function injectBackend(Tx_Extbase_Persistence_BackendInterface $backend) {
                $this->backend = $backend;
        }
-
        /**
+        *
         * Injects the persistence session
         *
         * @param Tx_Extbase_Persistence_Session $session The persistence session
index 0c0f78e..9801078 100644 (file)
@@ -38,7 +38,7 @@ class Tx_Extbase_Persistence_QueryFactory implements Tx_Extbase_Persistence_Quer
         * @return Tx_Extbase_Persistence_QueryInterface
         */
        public function create($className) {
-               $persistenceManager = t3lib_div::makeInstance('Tx_Extbase_Persistence_Manager'); // singleton; initialized in the dispatcher
+               $persistenceManager = t3lib_div::makeInstance('Tx_Extbase_Persistence_Manager'); // singleton; must have been initialized before
 
                $dataMapper = t3lib_div::makeInstance('Tx_Extbase_Persistence_Mapper_DataMapper');
                $dataMapper->injectIdentityMap($persistenceManager->getBackend()->getIdentityMap());
index 5d57865..ad1809c 100644 (file)
@@ -50,8 +50,7 @@ class Tx_Extbase_Persistence_Repository implements Tx_Extbase_Persistence_Reposi
         */
        public function __construct() {
                $this->queryFactory = t3lib_div::makeInstance('Tx_Extbase_Persistence_QueryFactory');
-               $this->persistenceManager = t3lib_div::makeInstance('Tx_Extbase_Persistence_Manager'); // singleton; must have been initialized before (constructor argument)
-               // FIXME This does not work for itemProcFunc()
+               $this->persistenceManager = t3lib_div::makeInstance('Tx_Extbase_Persistence_Manager'); // singleton; must have been initialized before
        }
 
        /**