/** * Returns the value of the cache config attribute or throws an exception, * in case the attribute is not given within the attributes array. * * @param string $name The name of the desired attribute. * * @return string Value of the attribute. * @throws InvalidArgumentException In case the desired attribute is not defined. * * @author Christian Achatz * @version * Version 0.1, 24.11.2008<br /> */ protected function getConfigAttribute($name) { $value = $this->configuration->getValue($name); if ($value == null) { $env = Registry::retrieve('APF\\core', 'Environment'); throw new InvalidArgumentException('[' . get_class($this) . '::getConfigAttribute()] The configuration directive "' . $name . '" is not present or empty. ' . 'Please check your cache configuration ("' . $env . '_cacheconfig.ini") for namespace ' . '"APF\\tools\\cache" and context "' . $this->getContext() . '" or consult the documentation!', E_USER_ERROR); } return $value; }
public function saveConfiguration($namespace, $context, $language, $environment, $name, Configuration $config) { $fileName = $this->getFilePath($namespace, $context, $language, $environment, $name); // create file path if necessary to avoid "No such file or directory" errors $this->createFilePath($fileName); /* @var $config StatementConfiguration */ if (file_put_contents($fileName, $config->getStatement()) === false) { throw new ConfigurationException('[StatementConfigurationProvider::saveConfiguration()] ' . 'Configuration with name "' . $fileName . '" cannot be saved! Please check your ' . 'file system configuration, the file name, or your environment configuration.'); } }
/** * Implements the init() method used by the service manager. Initializes the cache * manager with the corresponding cache configuration section. * * @param Configuration $initParam The desired cache config section. * * @author Christian Achatz * @version * Version 0.1, 21.11.2008<br /> * Version 0.2, 22.11.2008 (Refactored due to fabric introduction.)<br /> * Version 0.3, 24.11.2008 (Refactoring due to discussions on the fusion of writers and readers)<br /> * Version 0.4, 24.06.2014 (ID#207: Refactoring due to separation of attribute handling from APFObject)<br /> */ public function init($initParam) { $class = $initParam->getValue('Provider'); /* @var $provider CacheProvider */ $provider = $this->getServiceObject($class, [], APFService::SERVICE_TYPE_NORMAL); // inject configuration $provider->setConfiguration($initParam); $this->provider = $provider; // map the active configuration key $active = $initParam->getValue('Active'); if ($active == 'true') { $this->active = true; } }
/** * Erzeugt den JS Code zum Prüfen des MimeType * * @return string * * @author dave * @version 1.0, 14.07.2012 */ private function createMimeTypeCheck() { return ' var regexp = ' . $this->createFileExtensionForJS($this->manager->getMimeTypes()) . '; if (!regexp.test(files[index].name)) { $(".filetype_dialog").dialog({ modal: true,height:220,width:300, buttons: { "' . $this->languageConfig->getValue('filetype.ok') . '": function() { $(this).dialog("close"); } } }); handler.uploadRow.remove(); return; }'; }
/** * 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); } } }
/** * @param Configuration $config * @param SimpleXMLElement $section * * @author Christian Achatz * @version * Version 0.1, 09.10.2010<br /> */ private function parseSection(Configuration $config, SimpleXMLElement $section) { $config->setSection((string) $section->attributes()->name, $this->parseXmlElement($section)); }