[TASK] Extbase (MVC): Avoid code-duplication in Tx_Extbase_MVC_Web_FrontendRequestHan...
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 11 Jun 2011 21:59:44 +0000 (23:59 +0200)
committerSebastian Kurfuerst <sebastian@typo3.org>
Thu, 10 Nov 2011 09:16:02 +0000 (10:16 +0100)
Same functionality is available centrally through
Tx_Extbase_Service_ExtensionService::isActionCacheable()

Thanks to Marc Bastian Heinrichs for the idea.

Change-Id: I9d2c7eb2eec8eb58eaebd54b5446b3f88bae3675
Resolves: #13100

typo3/sysext/extbase/Classes/MVC/Web/FrontendRequestHandler.php

index 15eecce..7e7c255 100644 (file)
@@ -37,6 +37,11 @@ class Tx_Extbase_MVC_Web_FrontendRequestHandler extends Tx_Extbase_MVC_Web_Abstr
        protected $configurationManager;
 
        /**
+        * @var Tx_Extbase_Service_ExtensionService
+        */
+       protected $extensionService;
+
+       /**
         * @param Tx_Extbase_Configuration_ConfigurationManagerInterface $configurationManager
         * @return void
         */
@@ -45,6 +50,14 @@ class Tx_Extbase_MVC_Web_FrontendRequestHandler extends Tx_Extbase_MVC_Web_Abstr
        }
 
        /**
+        * @param Tx_Extbase_Service_ExtensionService $extensionService
+        * @return void
+        */
+       public function injectExtensionService(Tx_Extbase_Service_ExtensionService $extensionService) {
+               $this->extensionService = $extensionService;
+       }
+
+       /**
         * Handles the web request. The response will automatically be sent to the client.
         *
         * @return Tx_Extbase_MVC_Web_Response
@@ -56,7 +69,7 @@ class Tx_Extbase_MVC_Web_FrontendRequestHandler extends Tx_Extbase_MVC_Web_Abstr
                $requestHashService = $this->objectManager->get('Tx_Extbase_Security_Channel_RequestHashService'); // singleton
                $requestHashService->verifyRequest($request);
 
-               if ($this->isCacheable($request->getControllerName(), $request->getControllerActionName())) {
+               if ($this->extensionService->isActionCacheable(NULL, NULL, $request->getControllerName(), $request->getControllerActionName())) {
                        $request->setIsCached(TRUE);
                } else {
                        $contentObject = $this->configurationManager->getContentObject();
@@ -82,22 +95,5 @@ class Tx_Extbase_MVC_Web_FrontendRequestHandler extends Tx_Extbase_MVC_Web_Abstr
        public function canHandleRequest() {
                return TYPO3_MODE === 'FE';
        }
-
-       /**
-        * Determines whether the current action can be cached
-        *
-        * @param string $controllerName
-        * @param string $actionName
-        * @return boolean TRUE if the given action should be cached, otherwise FALSE
-        */
-       protected function isCacheable($controllerName, $actionName) {
-               $frameworkConfiguration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
-               if (isset($frameworkConfiguration['controllerConfiguration'][$controllerName]['nonCacheableActions'])
-                       && in_array($actionName, $frameworkConfiguration['controllerConfiguration'][$controllerName]['nonCacheableActions'])) {
-                               return FALSE;
-                       }
-               return TRUE;
-       }
-
 }
 ?>
\ No newline at end of file