Beispiel #1
0
 public function test_get_with_and_without_cache()
 {
     $expectedConfig = array('value1' => 1, 'value2' => 2, 'value3' => array('subvalue1' => 1, 'subvalue2' => 2, 'subvalue3' => 5, 'subvalue4' => array('subsubvalue1' => 2)));
     $config = $this->Config->get('testconfig1', 'testing');
     $this->assertEqual($expectedConfig, $config);
     $expectedConfig = array('value1' => 100, 'value2' => 2, 'value3' => array('subvalue1' => 1, 'subvalue2' => 2, 'subvalue3' => 7, 'subvalue4' => array('subsubvalue1' => 13)));
     $reader = new AkConfig(array('skip_cache' => true));
     $config = $reader->get('testconfig1', 'production');
     $this->assertEqual($expectedConfig, $config);
 }
Beispiel #2
0
 /**
  * Returns YAML settings from config/$namespace.yml
  */
 function getSettings($namespace, $raise_error_if_config_file_not_found = true, $environment = AK_ENVIRONMENT)
 {
     static $_config;
     if (!in_array($environment, Ak::toArray(AK_AVAILABLE_ENVIRONMENTS))) {
         trigger_error('The environment ' . $environment . ' is not allowed. Allowed environments: ' . AK_AVAILABLE_ENVIRONMENTS);
         return false;
     }
     if (!isset($_config)) {
         require_once AK_LIB_DIR . DS . 'AkConfig.php';
         $_config = new AkConfig();
     }
     return $_config->get($namespace, $environment, $raise_error_if_config_file_not_found);
 }
Beispiel #3
0
 function _checkDbConfig($type, $settings = array())
 {
     $this->debug('Checking if database config for "' . $type . '" is available');
     require_once AK_BASE_DIR . DS . 'lib' . DS . 'AkActiveRecord' . DS . 'AkDbAdapter.php';
     require_once AK_LIB_DIR . DS . 'Ak.php';
     if (empty($settings)) {
         require_once AK_BASE_DIR . DS . 'lib' . DS . 'AkConfig.php';
         $config = new AkConfig();
         $settings = $config->get($type, 'testing');
     }
     $db = new AkDbAdapter($settings);
     $db->connect(false);
     if (!($res = $db->connected())) {
         $this->error("[{$type}] " . 'Cannot connect to DB');
     } else {
         $this->info("[{$type}] " . 'Successfully connected to database ' . ($settings['type'] == 'sqlite' ? $settings['database_file'] : $settings['database_name']));
         $createRes = $db->execute('CREATE table ci_test_dummy(id integer)');
         if (!$createRes) {
             $res = false;
             $this->error("[{$type}] " . 'Could not create test table: ci_test_dummy');
         } else {
             $res = true;
             $this->info("[{$type}] " . 'Successfully created test table: ci_test_dummy');
             $db->execute('DROP table ci_test_dummy');
         }
     }
     return $res;
 }
Beispiel #4
0
 /**
  * Returns YAML settings from config/$namespace.yml
  */
 static function getSettings($namespace, $raise_error_if_config_file_not_found = true, $environment = AK_ENVIRONMENT)
 {
     static $_config;
     if ($raise_error_if_config_file_not_found && !in_array($environment, Ak::toArray(AK_AVAILABLE_ENVIRONMENTS))) {
         trigger_error('The environment ' . $environment . ' is not allowed. Allowed environments: ' . AK_AVAILABLE_ENVIRONMENTS, E_USER_ERROR);
         return false;
     }
     if (!isset($_config)) {
         $_config = new AkConfig();
     }
     return $_config->get($namespace, $environment, $raise_error_if_config_file_not_found);
 }
Beispiel #5
0
 private function load_config(){
   if(empty($this->config)){
     $config = new AkConfig();
     $this->config = $config->get('tpv',TPV_MODE);
     $unknown_properties = array();
     foreach($this->config as $conf => $value){
       if(in_array($conf,Payment::getProperties())){
         ($conf=='language' || $conf=='currency') && !is_numeric($value) && $value=constant($value);
         $this->$conf = $value;
       }else{
         $this->unknown_properties[] = $conf;
       }
     }
   }
   is_array($this->unknown_properties) && $this->unknown_properties = count($this->unknown_properties);
   return $this->unknown_properties;
 }