[BUGFIX] Wrong nested extension configuration handling
[Packages/TYPO3.CMS.git] / typo3 / sysext / extensionmanager / Classes / Controller / ConfigurationController.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2012 Susanne Moog, <typo3@susannemoog.de>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27
28
29 /**
30 * Controller for configuration related actions.
31 *
32 * @author Susanne Moog <typo3@susannemoog.de>
33 * @package Extension Manager
34 * @subpackage Controller
35 */
36 class Tx_Extensionmanager_Controller_ConfigurationController extends Tx_Extensionmanager_Controller_AbstractController {
37
38 /**
39 * @var Tx_Extensionmanager_Domain_Repository_ConfigurationItemRepository
40 */
41 protected $configurationItemRepository;
42
43 /**
44 * @param Tx_Extensionmanager_Domain_Repository_ConfigurationItemRepository $configurationItemRepository
45 * @return void
46 */
47 public function injectConfigurationItemRepository(
48 Tx_Extensionmanager_Domain_Repository_ConfigurationItemRepository $configurationItemRepository
49 ) {
50 $this->configurationItemRepository = $configurationItemRepository;
51 }
52
53 /**
54 * Show the extension configuration form. The whole form field handling is done
55 * in the corresponding view helper
56 *
57 * @return void
58 */
59 public function showConfigurationFormAction() {
60 $extension = $this->request->getArgument('extension');
61 $extension = array_merge($extension, $GLOBALS['TYPO3_LOADED_EXT'][$extension['key']]);
62 $configuration = $this->configurationItemRepository->findByExtension($extension);
63 $this->view
64 ->assign('configuration', $configuration)
65 ->assign('extension', $extension);
66 }
67
68 /**
69 * Save configuration to file
70 * Merges existing with new configuration.
71 *
72 * @param array $config The new extension configuration
73 * @param string $extensionKey The extension key
74 * @return void
75 */
76 public function saveAction(array $config, $extensionKey) {
77 /** @var $configurationUtility Tx_Extensionmanager_Utility_Configuration */
78 $configurationUtility = $this->objectManager->get('Tx_Extensionmanager_Utility_Configuration');
79 $currentFullConfiguration = $configurationUtility->getCurrentConfiguration($extensionKey);
80 $newConfiguration = t3lib_div::array_merge_recursive_overrule($currentFullConfiguration, $config);
81
82 $configurationUtility->writeConfiguration(
83 $configurationUtility->convertValuedToNestedConfiguration($newConfiguration),
84 $extensionKey
85 );
86 $this->redirect('showConfigurationForm', NULL, NULL, array('extension' => array('key' => $extensionKey)));
87 }
88
89
90 }
91 ?>