/** * Generates a package from it's single files. * Will Shrink output, if enabled. * * @param Configuration $cfgPack The package configuration * @param string $name The package name * * @return string All files put together to one string. * * @author Ralf Schubert * @version * Version 1.0, 18.03.2010<br /> * Version 1.1, 05.11.2010 (Fixed Bug, caused by incompatible use of new configuration methods)<br /> */ protected function generatePackage(Configuration $cfgPack, $name) { $output = ''; $files = $cfgPack->getSection('Files'); foreach ($files->getSectionNames() as $fileSectionName) { $file = $files->getSection($fileSectionName); $output .= $this->loadSingleFile($file->getValue('Namespace'), $file->getValue('Filename'), $cfgPack->getValue('PackageType'), $name); } if ($cfgPack->getValue('EnableShrinking') === 'true') { switch ($cfgPack->getValue('PackageType')) { case 'js': $output = $this->shrinkJs($output); break; case 'css': $output = $this->shrinkCSS($output); break; } } $this->initFilterChain($cfgPack->getValue('PackageType')); $output = JsCssInclusionFilterChain::getInstance()->filter($output); return $output; }
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; }
/** * 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; }
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); } } }
/** * 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); } }