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; }
/** * 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; }
protected function processValues(&$output, Configuration $config, $indention) { $valueNames = $config->getValueNames(); $valuesCount = count($valueNames); $i = 1; foreach ($valueNames as $valueName) { $this->processValue($output, $valueName, $config->getValue($valueName), $indention, $valuesCount == $i); $i++; } }
/** * 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); } }