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