Beispiel #1
0
 public function testArrayExtended()
 {
     $config = new \Phalcon\Config(array());
     $config['boolTrue'] = true;
     $this->assertEquals($config->offsetExists('boolTrue'), true);
     $this->assertEquals(isset($config['boolTrue']), true);
     $this->assertEquals(isset($config->boolTrue), true);
     $this->assertEquals($config['boolTrue'], true);
     $this->assertEquals($config->boolTrue, true);
     $this->assertEquals($config->get('boolTrue'), true);
     $this->assertEquals($config->offsetGet('boolTrue'), true);
     $config->offsetUnset('boolTrue');
     $this->assertEquals(isset($config['boolTrue']), false);
     $this->assertEquals($config['boolTrue'], null);
     $this->assertEquals($config->toArray(), array());
     $this->assertEquals($config->count(), 0);
     $config->a = 'b';
     $this->assertEquals($config->toArray(), array('a' => 'b'));
     $anotherConfig = new \Phalcon\Config(array('test' => 'data'));
     $config['config'] = $anotherConfig;
     $this->assertEquals($config->toArray(), array('a' => 'b', 'config' => array('test' => 'data')));
     unset($config->a);
     $this->assertEquals($config->count(), 1);
 }
Beispiel #2
0
|
| A simple system to fetch the app/config/config.php file and autoload 
| your custom config files added in the app/config/config.php into the 
| array "autoload => configs"
|
| @link http://docs.phalconphp.com/en/latest/api/Phalcon_Config.html
|
*/
// Init config var
$config = new \Phalcon\Config([]);
// Load config file of system
$tmp = (require APPPATH . 'config/config.php');
// Merge with the init config
$config->merge($tmp);
// Load custom config from autoload
if (isset($config->get('autoload')['configs'])) {
    $autoloadConfigs = $config->get('autoload')['configs'];
    if (!empty($autoloadConfigs)) {
        foreach ($autoloadConfigs as $configToLoad) {
            if (!empty($configToLoad)) {
                $tmp = (require APPPATH . 'config/' . $configToLoad . '.php');
                $config->merge($tmp);
            }
        }
    }
}
/*
|--------------------------------------------------------------------------
| Loader
|--------------------------------------------------------------------------
|