TYPO3 CMS  TYPO3_8-7
ConfigurationController.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
23 
28 {
33 
38 
42  public function injectConfigurationItemRepository(\TYPO3\CMS\Extensionmanager\Domain\Repository\ConfigurationItemRepository $configurationItemRepository)
43  {
44  $this->configurationItemRepository = $configurationItemRepository;
45  }
46 
50  public function injectExtensionRepository(\TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository $extensionRepository)
51  {
52  $this->extensionRepository = $extensionRepository;
53  }
54 
60  protected function initializeView(ViewInterface $view)
61  {
62  if ($view instanceof BackendTemplateView) {
64  parent::initializeView($view);
65  $this->generateMenu();
66  $this->registerDocheaderButtons();
67  }
68  }
69 
77  public function showConfigurationFormAction(array $extension)
78  {
79  if (!isset($extension['key'])) {
80  throw new ExtensionManagerException('Extension key not found.', 1359206803);
81  }
82  $this->handleTriggerArguments();
83 
84  $extKey = $extension['key'];
85  $configuration = $this->configurationItemRepository->findByExtensionKey($extKey);
86  if ($configuration) {
87  $this->view
88  ->assign('configuration', $configuration)
89  ->assign('extension', $extension);
90  } else {
91  throw new ExtensionManagerException('The extension ' . $extKey . ' has no configuration.', 1476047775);
92  }
93  }
94 
102  public function saveAction(array $config, $extensionKey)
103  {
104  $this->saveConfiguration($config, $extensionKey);
106  $extension = $this->extensionRepository->findOneByCurrentVersionByExtensionKey($extensionKey);
107  // Different handling for distribution installation
108  if ($extension instanceof Extension &&
110  ) {
111  $this->redirect('show', 'Distribution', null, ['extension' => $extension->getUid()]);
112  } else {
113  $this->redirect('showConfigurationForm', null, null, [
114  'extension' => [
115  'key' => $extensionKey
116  ],
117  self::TRIGGER_RefreshTopbar => true
118  ]);
119  }
120  }
121 
128  public function saveAndCloseAction(array $config, $extensionKey)
129  {
130  $this->saveConfiguration($config, $extensionKey);
131  $this->redirect('index', 'List', null, [
132  self::TRIGGER_RefreshTopbar => true
133  ]);
134  }
135 
142  protected function emitAfterExtensionConfigurationWriteSignal($extensionKey, array $newConfiguration)
143  {
144  $this->signalSlotDispatcher->dispatch(__CLASS__, 'afterExtensionConfigurationWrite', [$extensionKey, $newConfiguration, $this]);
145  }
146 
153  protected function saveConfiguration(array $config, $extensionKey)
154  {
156  $configurationUtility = $this->objectManager->get(\TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility::class);
157  $newConfiguration = $configurationUtility->getCurrentConfiguration($extensionKey);
159  $configurationUtility->writeConfiguration(
160  $configurationUtility->convertValuedToNestedConfiguration($newConfiguration),
161  $extensionKey
162  );
163  $this->emitAfterExtensionConfigurationWriteSignal($extensionKey, $newConfiguration);
164  }
165 
171  protected function registerDocheaderButtons()
172  {
173  $moduleTemplate = $this->view->getModuleTemplate();
174  $lang = $this->getLanguageService();
175 
177  $buttonBar = $moduleTemplate->getDocHeaderComponent()->getButtonBar();
178 
179  $uriBuilder = $this->controllerContext->getUriBuilder();
180  $uri = $uriBuilder->reset()->uriFor('index', [], 'List');
181 
182  $icon = $this->view->getModuleTemplate()->getIconFactory()->getIcon('actions-view-go-back', Icon::SIZE_SMALL);
183  $goBackButton = $buttonBar->makeLinkButton()
184  ->setHref($uri)
185  ->setTitle($this->translate('extConfTemplate.backToList'))
186  ->setIcon($icon);
187  $buttonBar->addButton($goBackButton, ButtonBar::BUTTON_POSITION_LEFT);
188 
189  $saveSplitButton = $buttonBar->makeSplitButton();
190  // SAVE button:
191  $saveButton = $buttonBar->makeInputButton()
192  ->setName('_savedok')
193  ->setValue('1')
194  ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.saveDoc'))
195  ->setForm('configurationform')
196  ->setIcon($moduleTemplate->getIconFactory()->getIcon('actions-document-save', Icon::SIZE_SMALL));
197  $saveSplitButton->addItem($saveButton, true);
198 
199  // SAVE / CLOSE
200  $saveAndCloseButton = $buttonBar->makeInputButton()
201  ->setName('_saveandclosedok')
202  ->setClasses('t3js-save-close')
203  ->setValue('1')
204  ->setTitle($lang->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:rm.saveCloseDoc'))
205  ->setForm('configurationform')
206  ->setIcon($moduleTemplate->getIconFactory()->getIcon(
207  'actions-document-save-close',
209  ));
210  $saveSplitButton->addItem($saveAndCloseButton);
211  $buttonBar->addButton($saveSplitButton, ButtonBar::BUTTON_POSITION_LEFT, 2);
212  }
213 
217  protected function getLanguageService()
218  {
219  return $GLOBALS['LANG'];
220  }
221 }
injectConfigurationItemRepository(\TYPO3\CMS\Extensionmanager\Domain\Repository\ConfigurationItemRepository $configurationItemRepository)
emitAfterExtensionConfigurationWriteSignal($extensionKey, array $newConfiguration)
redirect($actionName, $controllerName=null, $extensionName=null, array $arguments=null, $pageUid=null, $delay=0, $statusCode=303)
static mergeRecursiveWithOverrule(array &$original, array $overrule, $addKeys=true, $includeEmptyValues=true, $enableUnsetFeature=true)
injectExtensionRepository(\TYPO3\CMS\Extensionmanager\Domain\Repository\ExtensionRepository $extensionRepository)
if(TYPO3_MODE==='BE') $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tsfebeuserauth.php']['frontendEditingController']['default']