[!!!][~TASK] Extbase (Configuration): Major rework of the ConfigurationManager
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Classes / Configuration / FrontendConfigurationManager.php
index 9b80c0d..fb7cda8 100644 (file)
@@ -50,7 +50,7 @@ class Tx_Extbase_Configuration_FrontendConfigurationManager extends Tx_Extbase_C
         * @param array $frameworkConfiguration The framework configuration to modify
         * @return array the modified framework configuration
         */
-       protected function getContextSpecificFrameworkConfiguration($frameworkConfiguration) {
+       protected function getContextSpecificFrameworkConfiguration(array $frameworkConfiguration) {
                $frameworkConfiguration = $this->overrideStoragePidIfStartingPointIsSet($frameworkConfiguration);
                $frameworkConfiguration = $this->overrideConfigurationFromPlugin($frameworkConfiguration);
                $frameworkConfiguration = $this->overrideConfigurationFromFlexform($frameworkConfiguration);
@@ -65,7 +65,7 @@ class Tx_Extbase_Configuration_FrontendConfigurationManager extends Tx_Extbase_C
         * @param array $frameworkConfiguration the framework configurations
         * @return array the framework configuration with overriden storagePid
         */
-       protected function overrideStoragePidIfStartingPointIsSet($frameworkConfiguration) {
+       protected function overrideStoragePidIfStartingPointIsSet(array $frameworkConfiguration) {
                $pages = $this->contentObject->data['pages'];
                if (is_string($pages) && strlen($pages) > 0) {
                        $list = array();
@@ -171,7 +171,7 @@ class Tx_Extbase_Configuration_FrontendConfigurationManager extends Tx_Extbase_C
         * @param string $configurationPartName The name of the configuration part which should be merged.
         * @return array the processed framework configuration
         */
-       protected function mergeConfigurationIntoFrameworkConfiguration($frameworkConfiguration, $configuration, $configurationPartName) {
+       protected function mergeConfigurationIntoFrameworkConfiguration(array $frameworkConfiguration, array $configuration, $configurationPartName) {
                if (is_array($frameworkConfiguration[$configurationPartName]) && is_array($configuration[$configurationPartName])) {
                        $frameworkConfiguration[$configurationPartName] = t3lib_div::array_merge_recursive_overrule($frameworkConfiguration[$configurationPartName], $configuration[$configurationPartName]);
                }
@@ -182,46 +182,30 @@ class Tx_Extbase_Configuration_FrontendConfigurationManager extends Tx_Extbase_C
        /**
         * Overrides the switchable controller actions from the flexform.
         *
-        * @param $frameworkConfiguration The original framework configuration
-        * @param $flexformConfiguration The full flexform configuration
+        * @param array $frameworkConfiguration The original framework configuration
+        * @param array $flexformConfiguration The full flexform configuration
         * @return array the modified framework configuration, if needed
         * @todo: Check that the controller has been before inside the switchableControllerActions.
         */
-       protected function overrideSwitchableControllerActionsFromFlexform($frameworkConfiguration, $flexformConfiguration) {
-               if (isset($flexformConfiguration['switchableControllerActions']) && !is_array($flexformConfiguration['switchableControllerActions'])) {
-
-                       // As "," is the flexform field value delimiter, we need to use ";" as in-field delimiter. That's why we need to replace ; by  , first.
-                       $switchableControllerActionPartsFromFlexform = t3lib_div::trimExplode(',', str_replace(';', ',', $flexformConfiguration['switchableControllerActions']), TRUE);
+       protected function overrideSwitchableControllerActionsFromFlexform(array $frameworkConfiguration, array $flexformConfiguration) {
+               if (!isset($flexformConfiguration['switchableControllerActions']) || is_array($flexformConfiguration['switchableControllerActions'])) {
+                       return $frameworkConfiguration;
+               }
 
-                       $newSwitchableControllerActionsFromFlexform = array();
-                       foreach ($switchableControllerActionPartsFromFlexform as $switchableControllerActionPartFromFlexform) {
-                               list($controller, $action) = explode('->', $switchableControllerActionPartFromFlexform);
-                               if (empty($controller) || empty($action)) {
-                                       throw new Tx_Extbase_Configuration_Exception_ParseError('Controller or action were empty when overriding switchableControllerActions from flexform.', 1257146403);
-                               }
+               // As "," is the flexform field value delimiter, we need to use ";" as in-field delimiter. That's why we need to replace ; by  , first.
+               $switchableControllerActionPartsFromFlexform = t3lib_div::trimExplode(',', str_replace(';', ',', $flexformConfiguration['switchableControllerActions']), TRUE);
 
-                               $newSwitchableControllerActionsFromFlexform[$controller][] = $action;
+               $newSwitchableControllerActionsFromFlexform = array();
+               foreach ($switchableControllerActionPartsFromFlexform as $switchableControllerActionPartFromFlexform) {
+                       list($controller, $action) = explode('->', $switchableControllerActionPartFromFlexform);
+                       if (empty($controller) || empty($action)) {
+                               throw new Tx_Extbase_Configuration_Exception_ParseError('Controller or action were empty when overriding switchableControllerActions from flexform.', 1257146403);
                        }
+                       $newSwitchableControllerActionsFromFlexform[$controller][] = $action;
+               }
 
-                       if (count($newSwitchableControllerActionsFromFlexform)) {
-                               $overriddenSwitchableControllerActions = array();
-                               foreach ($newSwitchableControllerActionsFromFlexform as $controller => $actions) {
-                                       $overriddenSwitchableControllerActions[$controller] = array(
-                                               'controller' => $controller,
-                                               'actions' => implode(',', $actions)
-                                       );
-                                       $nonCacheableActions = t3lib_div::trimExplode(',', $frameworkConfiguration['switchableControllerActions'][$controller]['nonCacheableActions']);
-                                       $overriddenNonCacheableActions = array_intersect($nonCacheableActions, $actions);
-                                       if (!empty($overriddenNonCacheableActions)) {
-                                               $overriddenSwitchableControllerActions[$controller]['nonCacheableActions'] = implode(',', $overriddenNonCacheableActions);
-                                       }
-                               }
-                               $frameworkConfiguration['switchableControllerActions'] = $overriddenSwitchableControllerActions;
-
-                               // We want the first controller/action be the default.
-                               unset($frameworkConfiguration['controller']);
-                               unset($frameworkConfiguration['action']);
-                       }
+               if (count($newSwitchableControllerActionsFromFlexform)) {
+                       $this->overrideSwitchableControllerActions($frameworkConfiguration, $newSwitchableControllerActionsFromFlexform);
                }
                return $frameworkConfiguration;
        }