public function testSavingComplexStructure() { $config = new IniConfiguration(); $values = new IniConfiguration(); $values->setValue('ValueOne', 'foo'); $values->setValue('ValueTwo', 'bar'); $subSection = new IniConfiguration(); $subSection->setSection('SubSection', $values); $config->setSection('Section', $subSection); ConfigurationManager::saveConfiguration(self::TEST_VENDOR, null, null, self::TEST_ENVIRONMENT, self::TEST_NEW_CONFIG_NAME, $config); $storedConfig = ConfigurationManager::loadConfiguration(self::TEST_VENDOR, null, null, self::TEST_ENVIRONMENT, self::TEST_NEW_CONFIG_NAME); $this->assertEquals($config->getSection('Section')->getSection('SubSection')->getValue('ValueOne'), $storedConfig->getSection('Section')->getSection('SubSection')->getValue('ValueOne')); $this->assertEquals($config->getSection('Section')->getSection('SubSection')->getValue('ValueTwo'), $storedConfig->getSection('Section')->getSection('SubSection')->getValue('ValueTwo')); ConfigurationManager::deleteConfiguration(self::TEST_VENDOR, null, null, self::TEST_ENVIRONMENT, self::TEST_NEW_CONFIG_NAME); }
public function testSaveConfiguration() { $config = ConfigurationManager::loadConfiguration(self::TEST_VENDOR, null, null, self::TEST_ENVIRONMENT, self::TEST_CONFIG_NAME); ConfigurationManager::saveConfiguration(self::TEST_VENDOR, null, null, self::TEST_ENVIRONMENT, self::TEST_NEW_CONFIG_NAME, $config); $newConfig = ConfigurationManager::loadConfiguration(self::TEST_VENDOR, null, null, self::TEST_ENVIRONMENT, self::TEST_NEW_CONFIG_NAME); $this->assertEquals($config, $newConfig); $this->assertEquals($config->getValue('value 1'), $newConfig->getValue('value 1')); $this->assertEquals($config->getValue('value 2'), $newConfig->getValue('value 2')); $this->assertEquals($config->getValue('php-version'), $newConfig->getValue('php-version')); $this->assertInstanceOf(Configuration::class, $newConfig->getSection('section 1')); $this->assertInstanceOf(Configuration::class, $newConfig->getSection('section 1')->getSection('subsection 1')); $this->assertInstanceOf(Configuration::class, $newConfig->getSection('section 1')->getSection('subsection 2')); $this->assertEquals($config->getSection('section 1')->getSection('subsection 1')->getValue('value 1'), $newConfig->getSection('section 1')->getSection('subsection 1')->getValue('value 1')); $this->assertEquals($config->getSection('section 1')->getSection('subsection 1')->getValue('value 2'), $newConfig->getSection('section 1')->getSection('subsection 1')->getValue('value 2')); $this->assertEquals($config->getSection('section 1')->getSection('subsection 2')->getValue('value 1'), $newConfig->getSection('section 1')->getSection('subsection 2')->getValue('value 1')); $this->assertEquals($config->getSection('section 1')->getSection('subsection 2')->getValue('value 2'), $newConfig->getSection('section 1')->getSection('subsection 2')->getValue('value 2')); }
public function saveConfiguration($namespace, $context, $language, $environment, $name, Configuration $config) { $name = $this->remapConfigurationName($name); // saving the configuration always includes saving in both the // persistent file and the memcached store! $key = $this->getStoreIdentifier($namespace, $context, $language, $environment, $name); $this->memcachedService->replace($key, $config, 0, $this->expireTime); ConfigurationManager::saveConfiguration($namespace, $context, $language, $environment, $name, $config); }
/** * Convenience method for saving a configuration depending on APF DOM attributes and * the current environment. * * @param string $namespace The namespace of the configuration. * @param string $name The name of the configuration including it's extension. * @param Configuration $config The configuration to save. * * @author Christian Achatz * @version * Version 0.1, 28.10.2010<br /> */ protected function saveConfiguration($namespace, $name, Configuration $config) { ConfigurationManager::saveConfiguration($namespace, $this->getContext(), $this->getLanguage(), Registry::retrieve('APF\\core', 'Environment'), $name, $config); }