private function generateComplexConfigValue(Configuration $config, $currentName)
 {
     $buffer = '';
     // append simple values
     foreach ($config->getValueNames() as $name) {
         $value = $config->getValue($name);
         if (is_array($value)) {
             foreach ($value as $element) {
                 $buffer .= $currentName . '.' . $name . '[] = "' . $element . '"' . PHP_EOL;
             }
         } else {
             $buffer .= $currentName . '.' . $name . ' = "' . $value . '"' . PHP_EOL;
         }
     }
     // append sections
     foreach ($config->getSectionNames() as $name) {
         $buffer .= $this->generateComplexConfigValue($config->getSection($name), $currentName . '.' . $name);
     }
     return $buffer;
 }
 protected function processSection(&$output, $sectionName, Configuration $section, $indention)
 {
     $output .= str_repeat(' ', $indention) . '\'' . $sectionName . '\' => [' . PHP_EOL;
     foreach ($section->getSectionNames() as $sectionName) {
         $this->processSection($output, $sectionName, $section->getSection($sectionName), $indention + 3);
     }
     $this->processValues($output, $section, $indention + 3);
     $output .= str_repeat(' ', $indention) . '],' . PHP_EOL;
 }
 public function saveConfiguration($namespace, $context, $language, $environment, $name, Configuration $config)
 {
     $table = 'config_' . $this->getTableNameSuffix($namespace);
     // resolve entries by section since we have a flat structure only
     $conn = $this->getConnection($context, $language);
     $configName = $this->getConfigName($name);
     foreach ($config->getSectionNames() as $sectionName) {
         $section = $config->getSection($sectionName);
         foreach ($section->getValueNames() as $valueName) {
             $insert = 'INSERT INTO `' . $table . '`
                           SET
                              `context` = \'' . $context . '\',
                              `language` = \'' . $language . '\',
                              `environment` = \'' . $environment . '\',
                              `name` = \'' . $configName . '\',
                              `section` = \'' . $sectionName . '\',
                              `key` = \'' . $valueName . '\',
                              `value` = \'' . $section->getValue($valueName) . '\'
                           ON DUPLICATE KEY UPDATE
                              `value` = \'' . $section->getValue($valueName) . '\',
                              `modificationtimestamp` = NOW()';
             $conn->executeTextStatement($insert);
         }
     }
 }
 /**
  * Resolves the configuration abstraction to the array meta format concerning one section.
  *
  * @param Configuration $config The config to resolve.
  *
  * @return array The meta structure of the given configuration representation.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 07.11.2010<br />
  */
 private function resolveSection(Configuration $config)
 {
     $rawConfig = [];
     foreach ($config->getValueNames() as $name) {
         $rawConfig[$name] = $config->getValue($name);
     }
     foreach ($config->getSectionNames() as $name) {
         $rawConfig[$name] = $this->resolveSection($config->getSection($name));
     }
     return $rawConfig;
 }
 /**
  * Transforms a given config section into the applied xml structure.
  *
  * @param SimpleXMLElement $xml The parent XML node.
  * @param Configuration $config The current section to translate.
  * @param string $name The name of the section to add.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 28.10.2010<br />
  */
 private function processSection(SimpleXMLElement &$xml, Configuration $config, $name)
 {
     // create current section and append it to the parent node structure.
     $section = $xml->addChild('section');
     $section->addAttribute('name', $name);
     // add values
     foreach ($config->getValueNames() as $valueName) {
         $property = $section->addChild('property', $config->getValue($valueName));
         $property->addAttribute('name', $valueName);
     }
     // add sections recursively
     foreach ($config->getSectionNames() as $sectionName) {
         $this->processSection($section, $config->getSection($sectionName), $sectionName);
     }
 }