Index: Classes/Configuration/AbstractConfigurationManager.php =================================================================== --- Classes/Configuration/AbstractConfigurationManager.php (revision 1801) +++ Classes/Configuration/AbstractConfigurationManager.php (working copy) @@ -88,6 +88,9 @@ if (isset($pluginConfiguration['view'])) { $pluginConfiguration = $this->resolveTyposcriptReference($pluginConfiguration, 'view'); } + if (isset($pluginConfiguration['controllerAndActionPresets'])) { + $pluginConfiguration = $this->resolveTyposcriptReference($pluginConfiguration, 'controllerAndActionPresets'); + } if (isset($pluginConfiguration['_LOCAL_LANG'])) { $pluginConfiguration = $this->resolveTyposcriptReference($pluginConfiguration, '_LOCAL_LANG'); } Index: Classes/Configuration/FrontendConfigurationManager.php =================================================================== --- Classes/Configuration/FrontendConfigurationManager.php (revision 1801) +++ Classes/Configuration/FrontendConfigurationManager.php (working copy) @@ -191,24 +191,52 @@ * @todo: Check that the controller has been before inside the switchableControllerActions. */ protected function overrideSwitchableControllerActionsFromFlexform($frameworkConfiguration, $flexformConfiguration) { - if (isset($flexformConfiguration['switchableControllerActions']) && !is_array($flexformConfiguration['switchableControllerActions'])) { + if (isset($flexformConfiguration['switchableControllerActions']) && !is_array($flexformConfiguration['switchableControllerActions']) && !empty($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'])); $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); + // check if the flexform configuration is refering to a preset + if (substr($switchableControllerActionPartFromFlexform, 0, 8) == 'preset::') { + $presetName = array_pop(t3lib_div::trimExplode('::', $switchableControllerActionPartFromFlexform)); + // if we have a preset configuration, process it and add it to the newSwitchableControllerActionsFromFlexform + if (isset($frameworkConfiguration['controllerAndActionPresets'][$presetName])) { + $presetConfiguration = $frameworkConfiguration['controllerAndActionPresets'][$presetName]; + + // add default action to switchableController Actions + if (isset($presetConfiguration['controller']) && isset($presetConfiguration['action'])) { + $newSwitchableControllerActionsFromFlexform[$presetConfiguration['controller']][] = $presetConfiguration['action']; + } + + // if switchable actions are defined for the preset, add them + if (isset($presetConfiguration['switchableControllerActions']) && is_array($presetConfiguration['switchableControllerActions']) && count($presetConfiguration['switchableControllerActions'])) { + foreach ($presetConfiguration['switchableControllerActions'] as $switchableControllerActionFromPreset) { + $controller = $switchableControllerActionFromPreset['controller']; + $actions = t3lib_div::trimExplode(',', $switchableControllerActionFromPreset['actions']); + if (isset($newSwitchableControllerActionsFromFlexform[$controller])) { + $newSwitchableControllerActionsFromFlexform[$controller] = array_merge($newSwitchableControllerActionsFromFlexform[$controller], $actions); + } else { + $newSwitchableControllerActionsFromFlexform[$controller] = $actions; + } + } + } + } + } else { + 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; } - - $newSwitchableControllerActionsFromFlexform[$controller][] = $action; } if (count($newSwitchableControllerActionsFromFlexform)) { $frameworkConfiguration['switchableControllerActions'] = array(); foreach ($newSwitchableControllerActionsFromFlexform as $controller => $actions) { + $actions = array_unique($actions); $frameworkConfiguration['switchableControllerActions'][] = array( 'controller' => $controller, 'actions' => implode(',', $actions) @@ -220,6 +248,14 @@ unset($frameworkConfiguration['action']); } } + + // check if the default controller and action are defined in a seperate field and if so, apply them + if (isset($flexformConfiguration['defaultControllerAndAction']) && !empty($flexformConfiguration['defaultControllerAndAction'])) { + list ($controller, $action) = explode('->', $flexformConfiguration['defaultControllerAndAction']); + $frameworkConfiguration['controller'] = $controller; + $frameworkConfiguration['action'] = $action; + } + return $frameworkConfiguration; } }