Ejemplo n.º 1
0
 public function testMain()
 {
     $cf = new Configuration('test');
     $cf->write('hoge', 'fuga');
     $this->assertEquals($cf->read('hoge'), 'fuga');
     $cf->write('a.b.c', 'aaaa');
     $this->assertTrue(is_array($cf->read('a.b')));
     $this->assertEquals($cf->read('a.b.c'), 'aaaa');
     $cf->loadFile(TEST_DIR . '/config/load_test.php');
     $cf->loadDir(TEST_DIR . '/config/test', null, ['all', 'dev']);
     $spec = $cf->read('service.logger');
     $logger = call_user_func($spec['class'] . '::' . $spec['method'], $spec['config']);
     $logger->info('ちゃんとロガーが起動できました');
     $cf->save();
 }
Ejemplo n.º 2
0
 /**
  * ビルド
  */
 public static function build($name, $dir, $env = ['all', 'dev'], $useCache = true)
 {
     $name = $name . '.' . implode('.', $env);
     if ($useCache) {
         $file = Context::singleton()->getCachePath("config", $name);
         if (file_exists($file)) {
             $c = self::restore($name);
             $c->_cache = true;
             return $c;
         }
     }
     $c = new Configuration($name);
     $c->loadDir($dir, null, $env);
     $c->_cache = false;
     $c->save();
     return $c;
 }