/**
  * Show the extension configuration form. The whole form field handling is done
  * in the corresponding view helper
  *
  * @return void
  */
 public function showConfigurationFormAction()
 {
     $extension = $this->request->getArgument('extension');
     $extension = array_merge($extension, $GLOBALS['TYPO3_LOADED_EXT'][$extension['key']]);
     $configuration = $this->configurationItemRepository->findByExtension($extension);
     $this->view->assign('configuration', $configuration)->assign('extension', $extension);
 }
예제 #2
0
 /**
  * Get current configuration of an extension
  *
  * @param string $extensionKey
  * @return array
  */
 public function getCurrentConfiguration($extensionKey)
 {
     $extension = $GLOBALS['TYPO3_LOADED_EXT'][$extensionKey];
     $defaultConfig = $this->configurationItemRepository->createArrayFromConstants(\TYPO3\CMS\Core\Utility\GeneralUtility::getUrl(PATH_site . $extension['siteRelPath'] . '/ext_conf_template.txt'), $extension);
     $currentExtensionConfig = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extension['key']]);
     $currentExtensionConfig = is_array($currentExtensionConfig) ? $currentExtensionConfig : array();
     $currentFullConfiguration = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($defaultConfig, $currentExtensionConfig);
     return $currentFullConfiguration;
 }
 /**
  * Show the extension configuration form. The whole form field handling is done
  * in the corresponding view helper
  *
  * @param array $extension Extension information, must contain at least the key
  * @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
  * @return void
  */
 public function showConfigurationFormAction(array $extension)
 {
     if (!array_key_exists('key', $extension)) {
         throw new ExtensionManagerException('Extension key not found.', 1359206803);
     }
     $configuration = $this->configurationItemRepository->findByExtensionKey($extension['key']);
     if ($configuration) {
         $this->view->assign('configuration', $configuration)->assign('extension', $extension);
     } else {
         /** @var Extension $extension */
         $extension = $this->extensionRepository->findOneByCurrentVersionByExtensionKey($extension['key']);
         // Extension has no configuration and is a distribution
         if ($extension->getCategory() === Extension::DISTRIBUTION_CATEGORY) {
             $this->redirect('welcome', 'Distribution', NULL, array('extension' => $extension->getUid()));
         }
         throw new ExtensionManagerException('The extension ' . htmlspecialchars($extension['key']) . ' has no configuration.');
     }
 }
예제 #4
0
 /**
  * Show the extension configuration form. The whole form field handling is done
  * in the corresponding view helper
  *
  * @param array $extension Extension information, must contain at least the key
  * @throws \TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException
  * @return void
  */
 public function showConfigurationFormAction(array $extension)
 {
     if (!isset($extension['key'])) {
         throw new ExtensionManagerException('Extension key not found.', 1359206803);
     }
     $extKey = $extension['key'];
     $configuration = $this->configurationItemRepository->findByExtensionKey($extKey);
     if ($configuration) {
         $this->view->assign('configuration', $configuration)->assign('extension', $extension);
     } else {
         /** @var Extension $extension */
         $extension = $this->extensionRepository->findOneByCurrentVersionByExtensionKey($extKey);
         // Extension has no configuration and is a distribution
         if ($extension->getCategory() === Extension::DISTRIBUTION_CATEGORY) {
             $this->redirect('welcome', 'Distribution', null, ['extension' => $extension->getUid()]);
         }
         throw new ExtensionManagerException('The extension ' . $extKey . ' has no configuration.', 1476047775);
     }
 }
 /**
  * @test
  * @return void
  */
 public function mergeWithExistingConfigurationOverwritesDefaultKeysWithCurrent()
 {
     $backupExtConf = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'];
     $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['testextensionkey'] = serialize(array('FE.' => array('enabled' => '1', 'saltedPWHashingMethod' => 'TYPO3\\CMS\\Saltedpasswords\\Salt\\SaltInterface_sha1'), 'CLI.' => array('enabled' => '0')));
     $defaultConfiguration = array('FE.enabled' => array('value' => '0'), 'FE.saltedPWHashingMethod' => array('value' => 'TYPO3\\CMS\\Saltedpasswords\\Salt\\Md5Salt'), 'BE.enabled' => array('value' => '1'), 'BE.saltedPWHashingMethod' => array('value' => 'TYPO3\\CMS\\Saltedpasswords\\Salt\\Md5Salt'));
     $expectedResult = array('FE.enabled' => array('value' => '1'), 'FE.saltedPWHashingMethod' => array('value' => 'TYPO3\\CMS\\Saltedpasswords\\Salt\\SaltInterface_sha1'), 'BE.enabled' => array('value' => '1'), 'BE.saltedPWHashingMethod' => array('value' => 'TYPO3\\CMS\\Saltedpasswords\\Salt\\Md5Salt'), 'CLI.enabled' => array('value' => '0'));
     $result = $this->configurationItemRepository->mergeWithExistingConfiguration($defaultConfiguration, array('key' => 'testextensionkey'));
     $this->assertEquals($expectedResult, $result);
     $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'] = $backupExtConf;
 }
 /**
  * @test
  * @return void
  */
 public function mergeWithExistingConfigurationOverwritesDefaultKeysWithCurrent()
 {
     $localConfiguration = serialize(array('FE.' => array('enabled' => '1', 'saltedPWHashingMethod' => \TYPO3\CMS\Saltedpasswords\Salt\SaltInterface_sha1::class), 'CLI.' => array('enabled' => '0')));
     $configurationManagerMock = $this->getMock(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class);
     $configurationManagerMock->expects($this->once())->method('getConfigurationValueByPath')->with('EXT/extConf/testextensionkey')->will($this->returnValue($localConfiguration));
     $this->injectedObjectManagerMock->expects($this->any())->method('get')->will($this->returnValue($configurationManagerMock));
     $defaultConfiguration = array('FE.enabled' => array('value' => '0'), 'FE.saltedPWHashingMethod' => array('value' => \TYPO3\CMS\Saltedpasswords\Salt\Md5Salt::class), 'BE.enabled' => array('value' => '1'), 'BE.saltedPWHashingMethod' => array('value' => \TYPO3\CMS\Saltedpasswords\Salt\Md5Salt::class));
     $expectedResult = array('FE.enabled' => array('value' => '1'), 'FE.saltedPWHashingMethod' => array('value' => \TYPO3\CMS\Saltedpasswords\Salt\SaltInterface_sha1::class), 'BE.enabled' => array('value' => '1'), 'BE.saltedPWHashingMethod' => array('value' => \TYPO3\CMS\Saltedpasswords\Salt\Md5Salt::class), 'CLI.enabled' => array('value' => '0'));
     $actualResult = $this->configurationItemRepository->_call('mergeWithExistingConfiguration', $defaultConfiguration, 'testextensionkey');
     $this->assertEquals($expectedResult, $actualResult);
 }
    /**
     * @test
     */
    public function convertRawConfigurationToArrayReturnsSortedHierarchicArray()
    {
        $configRaw = '# cat=basic/enable/10; type=string; label=Item 1: This is the first configuration item
item1 = one

# cat=basic/enable/20; type=int+; label=Integer Value: Please insert a positive integer value
integerValue = 1

# cat=advanced/file/10; type=boolean; label=enableJquery: Insert jQuery plugin
enableJquery = 1';
        $extension = array();
        $expectedArray = array('basic' => array('enable' => array('item1' => array('cat' => 'basic', 'subcat_name' => 'enable', 'subcat' => 'a/enable/10z', 'type' => 'string', 'label' => 'Item 1: This is the first configuration item', 'name' => 'item1', 'value' => 'one', 'default_value' => 'one', 'labels' => array(0 => 'Item 1', 1 => 'This is the first configuration item')), 'integerValue' => array('cat' => 'basic', 'subcat_name' => 'enable', 'subcat' => 'a/enable/20z', 'type' => 'int+', 'label' => 'Integer Value: Please insert a positive integer value', 'name' => 'integerValue', 'value' => '1', 'default_value' => '1', 'labels' => array(0 => 'Integer Value', 1 => 'Please insert a positive integer value')))), 'advanced' => array('file' => array('enableJquery' => array('cat' => 'advanced', 'subcat_name' => 'file', 'subcat' => 'c/file/10z', 'type' => 'boolean', 'label' => 'enableJquery: Insert jQuery plugin', 'name' => 'enableJquery', 'value' => '1', 'default_value' => '1', 'labels' => array(0 => 'enableJquery', 1 => 'Insert jQuery plugin')))));
        $this->assertSame($expectedArray, $this->configurationItemRepository->_callRef('convertRawConfigurationToArray', $configRaw, $extension));
    }