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 loadConfiguration($namespace, $context, $language, $environment, $name)
 {
     $name = $this->remapConfigurationName($name);
     // try to get the configuration from the memcached store first if not available, read
     // persistent configuration and store it
     $key = $this->getStoreIdentifier($namespace, $context, $language, $environment, $name);
     $config = $this->memcachedService->get($key);
     if ($config === false) {
         $config = ConfigurationManager::loadConfiguration($namespace, $context, $language, $environment, $name);
         $this->memcachedService->set($key, $config, 0, $this->expireTime);
     }
     return $config;
 }
Esempio n. 3
0
 /**
  * Convenience method for loading 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.
  *
  * @return Configuration The desired configuration.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 28.09.2010<br />
  */
 protected function getConfiguration($namespace, $name)
 {
     return ConfigurationManager::loadConfiguration($namespace, $this->getContext(), $this->getLanguage(), Registry::retrieve('APF\\core', 'Environment'), $name);
 }
 public function testValueAccessWithPath()
 {
     $config = ConfigurationManager::loadConfiguration(self::TEST_VENDOR, null, null, self::TEST_ENVIRONMENT, self::TEST_CONFIG_NAME);
     $this->assertEquals('foo', $config->getValue('Section.SubSection.ValueOne'));
 }
Esempio n. 5
0
 /**
  * Loads the service configuration.
  *
  * @param string $configNamespace The namespace of the service (a.k.a. config namespace).
  * @param string $context The context of the current application.
  * @param string $language The language of the current application.
  * @param string $cacheKey The cache key to check/find configuration in configuration cache
  *
  * @return Configuration The appropriate configuration.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 04.10.2010<br />
  * Version 0.2, 15.07.2012 Jan Wiese (Introduced configuration cache and $cacheKey parameter)<br />
  */
 private static function getServiceConfiguration($configNamespace, $context, $language, $cacheKey)
 {
     // return cached version as much as possible to gain performance
     if (isset(self::$SERVICE_CONFIG_CACHE[$cacheKey])) {
         return self::$SERVICE_CONFIG_CACHE[$cacheKey];
     }
     self::$SERVICE_CONFIG_CACHE[$cacheKey] = ConfigurationManager::loadConfiguration($configNamespace, $context, $language, Registry::retrieve('APF\\core', 'Environment'), 'serviceobjects.' . self::$configurationExtension);
     return self::$SERVICE_CONFIG_CACHE[$cacheKey];
 }