/**
  * Merge current local configuration over default configuration
  *
  * @param array $defaultConfiguration Default configuration from ext_conf_template.txt
  * @param string $extensionKey the extension information
  * @return array
  */
 protected function mergeWithExistingConfiguration(array $defaultConfiguration, $extensionKey)
 {
     try {
         $currentExtensionConfig = unserialize($this->objectManager->get(\TYPO3\CMS\Core\Configuration\ConfigurationManager::class)->getConfigurationValueByPath('EXT/extConf/' . $extensionKey));
         if (!is_array($currentExtensionConfig)) {
             $currentExtensionConfig = array();
         }
     } catch (\RuntimeException $e) {
         $currentExtensionConfig = array();
     }
     $flatExtensionConfig = ArrayUtility::flatten($currentExtensionConfig);
     $valuedCurrentExtensionConfig = array();
     foreach ($flatExtensionConfig as $key => $value) {
         $valuedCurrentExtensionConfig[$key]['value'] = $value;
     }
     ArrayUtility::mergeRecursiveWithOverrule($defaultConfiguration, $valuedCurrentExtensionConfig);
     return $defaultConfiguration;
 }
示例#2
0
 /**
  * @test
  * @param array $array
  * @param array $expected
  * @dataProvider flattenCalculatesExpectedResultDataProvider
  */
 public function flattenCalculatesExpectedResult(array $array, array $expected)
 {
     $this->assertEquals($expected, ArrayUtility::flatten($array));
 }
 /**
  * Generates a Backend Layout from PageTsConfig array
  *
  * @return mixed
  */
 protected function generateBackendLayoutFromTsConfig($identifier, $data)
 {
     if (!empty($data['config.']['backend_layout.']) && is_array($data['config.']['backend_layout.'])) {
         $backendLayout['uid'] = substr($identifier, 0, -1);
         $backendLayout['title'] = $data['title'] ? $data['title'] : $backendLayout['uid'];
         $backendLayout['icon'] = $data['icon'] ? $data['icon'] : '';
         /* Convert PHP array back to plain TypoScript so it can be procecced */
         $config = \TYPO3\CMS\Core\Utility\ArrayUtility::flatten($data['config.']);
         $backendLayout['config'] = '';
         foreach ($config as $row => $value) {
             $backendLayout['config'] .= $row . " = " . $value . "\r\n";
         }
         return $backendLayout;
     }
     return NULL;
 }
 /**
  * Merge new configuration with existing configuration
  *
  * @param array $configuration the new configuration array
  * @param array $extension the extension information
  * @return array
  */
 protected function mergeWithExistingConfiguration(array $configuration, array $extension)
 {
     try {
         $currentExtensionConfig = unserialize($this->configurationManager->getConfigurationValueByPath('EXT/extConf/' . $extension['key']));
     } catch (\RuntimeException $e) {
         $currentExtensionConfig = array();
     }
     $flatExtensionConfig = \TYPO3\CMS\Core\Utility\ArrayUtility::flatten($currentExtensionConfig);
     $valuedCurrentExtensionConfig = array();
     foreach ($flatExtensionConfig as $key => $value) {
         $valuedCurrentExtensionConfig[$key]['value'] = $value;
     }
     $configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($configuration, $valuedCurrentExtensionConfig);
     return $configuration;
 }
 /**
  * @param array $array
  * @param array $expected
  * @test
  * @dataProvider arrayIsFlatDataProvider
  */
 public function arrayIsFlat(array $array, array $expected)
 {
     $this->assertEquals($expected, \TYPO3\CMS\Core\Utility\ArrayUtility::flatten($array));
 }
 /**
  * Convert a nested configuration to a valued configuration
  *
  * array('first.' => array('second' => 1))
  * will become
  * array('first.second' => array('value' => 1)
  * @param array $nestedConfiguration
  * @return array
  */
 public function convertNestedToValuedConfiguration(array $nestedConfiguration)
 {
     $flatExtensionConfig = \TYPO3\CMS\Core\Utility\ArrayUtility::flatten($nestedConfiguration);
     $valuedCurrentExtensionConfig = array();
     foreach ($flatExtensionConfig as $key => $value) {
         $valuedCurrentExtensionConfig[$key]['value'] = $value;
     }
     return $valuedCurrentExtensionConfig;
 }
 /**
  * Merge new configuration with existing configuration
  *
  * @param array $configuration the new configuration array
  * @param array $extension the extension information
  * @return array
  */
 protected function mergeWithExistingConfiguration(array $configuration, array $extension)
 {
     $currentExtensionConfig = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$extension['key']]);
     $flatExtensionConfig = \TYPO3\CMS\Core\Utility\ArrayUtility::flatten($currentExtensionConfig);
     $valuedCurrentExtensionConfig = array();
     foreach ($flatExtensionConfig as $key => $value) {
         $valuedCurrentExtensionConfig[$key]['value'] = $value;
     }
     if (is_array($currentExtensionConfig)) {
         $configuration = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($configuration, $valuedCurrentExtensionConfig);
     }
     return $configuration;
 }