[+BUGFIX] Extbase (MVC): Flashmessages now share a scope throughout the extension...
authorBastian Waidelich <bastian@typo3.org>
Mon, 15 Nov 2010 11:20:00 +0000 (11:20 +0000)
committerBastian Waidelich <bastian@typo3.org>
Mon, 15 Nov 2010 11:20:00 +0000 (11:20 +0000)
[~TASK] Extbase (Core): The Flashmessages now get persisted in the Bootstrap in resetSingletons()
[-TASK] Extbase (Core): Removed some commented lines from Bootstrap

typo3/sysext/extbase/Classes/Core/Bootstrap.php
typo3/sysext/extbase/Classes/MVC/Controller/FlashMessages.php
typo3/sysext/extbase/Classes/MVC/Web/BackendRequestHandler.php
typo3/sysext/extbase/Classes/MVC/Web/FrontendRequestHandler.php

index bcddf35..98a97c7 100644 (file)
@@ -93,14 +93,10 @@ class Tx_Extbase_Core_Bootstrap {
                $this->initializeObjectManager();
                $this->initializeConfiguration($configuration);
                $this->configureObjectManager();
-               // $this->initializeExtensions();
                $this->initializeCache();
                $this->initializeReflection();
-
                $this->initializePersistence();
                $this->initializeBackwardsCompatibility();
-               // $this->initializeSession();
-               // $this->initializeLocale();
                $this->isInitialized = TRUE;
        }
 
@@ -127,11 +123,6 @@ class Tx_Extbase_Core_Bootstrap {
         */
        protected function initializeObjectManager() {
                $this->objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
-               // $this->objectManager->injectClassLoader($this->classLoader);
-               // $this->objectManager->injectConfigurationManager($this->configurationManager);
-               // $this->objectManager->setContext($this->context);
-
-               // $this->objectManager->initialize();
        }
 
        /**
@@ -246,14 +237,12 @@ class Tx_Extbase_Core_Bootstrap {
                $requestHandler->setContentObject($this->cObj);
 
                $response = $requestHandler->handleRequest();
-
-               $this->persistenceManager->persistAll();
-               // $this->objectManager->shutdown();
                if (count($response->getAdditionalHeaderData()) > 0) {
                        $GLOBALS['TSFE']->additionalHeaderData[] = implode('', $response->getAdditionalHeaderData());
                }
                $response->sendHeaders();
                $content = $response->getContent();
+
                $this->resetSingletons();
                return $content;
        }
@@ -264,8 +253,9 @@ class Tx_Extbase_Core_Bootstrap {
         * @return void
         */
        protected function resetSingletons() {
+               $this->persistenceManager->persistAll();
+               $this->objectManager->get('Tx_Extbase_MVC_Controller_FlashMessages')->persist();
                $this->reflectionService->shutdown();
-               $this->objectManager->get('Tx_Extbase_MVC_Controller_FlashMessages')->reset();
        }
 
         /**
index c0cb599..343397b 100644 (file)
@@ -78,7 +78,9 @@ class Tx_Extbase_MVC_Controller_FlashMessages implements t3lib_Singleton {
         * @api
         */
        public function add($message) {
-               if (!is_string($message)) throw new InvalidArgumentException('The flash message must be string, ' . gettype($message) . ' given.', 1243258395);
+               if (!is_string($message)) {
+                       throw new InvalidArgumentException('The flash message must be string, ' . gettype($message) . ' given.', 1243258395);
+               }
                $this->initialize();
                $this->flashMessages[] = $message;
        }
@@ -125,7 +127,7 @@ class Tx_Extbase_MVC_Controller_FlashMessages implements t3lib_Singleton {
                if ($this->initialized) return;
 
                $frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
-               $this->flashMessageStorageKey = 'Tx_Extbase_MVC_Controller_FlashMessages_messages_' . $frameworkConfiguration['extensionName'] . $frameworkConfiguration['pluginName'];
+               $this->flashMessageStorageKey = 'Tx_Extbase_MVC_Controller_FlashMessages_messages_' . $frameworkConfiguration['extensionName'];
 
                $flashMessages = $this->loadFlashMessagesFromSession();
                if (is_array($flashMessages)) {
@@ -139,7 +141,6 @@ class Tx_Extbase_MVC_Controller_FlashMessages implements t3lib_Singleton {
         * Loads the flash messages from the current user session.
         */
        protected function loadFlashMessagesFromSession() {
-               $flashMessages = NULL;
                if (TYPO3_MODE === 'FE') {
                        $flashMessages = $GLOBALS['TSFE']->fe_user->getKey('ses', $this->flashMessageStorageKey);
                } else {
index 06c06d6..390ba70 100644 (file)
@@ -42,8 +42,6 @@ class Tx_Extbase_MVC_Web_BackendRequestHandler extends Tx_Extbase_MVC_Web_Abstra
 
                $this->dispatcher->dispatch($request, $response);
 
-               $this->flashMessages->persist();
-
                return $response;
        }
 
index 9888e32..4c0bb3f 100644 (file)
@@ -61,8 +61,6 @@ class Tx_Extbase_MVC_Web_FrontendRequestHandler extends Tx_Extbase_MVC_Web_Abstr
 
                $this->dispatcher->dispatch($request, $response);
 
-               $this->flashMessages->persist();
-
                return $response;
        }