westdc-core/Westdc/Helpers/Config.php

47 lines
908 B
PHP
Raw Normal View History

<?php
namespace Westdc\Helpers;
class Config
{
2015-01-09 15:33:25 +00:00
function __construct()
{
//$reader = new \Zend\Config\Reader\Ini();
//$data = $reader->fromFile('config/config.ini');
}
2015-01-09 15:33:25 +00:00
static function get($configName = 'global')
{
2015-01-09 15:33:25 +00:00
if(defined(CONFIG_PATH))
{
throw new \RuntimeException('Not found the config files path');
}
$config_path = CONFIG_PATH;
if(empty($configName))
$configName = "global.php";
if(!preg_match("/(\\/|\\\)$/",$config_path))
{
$config_path .= "/";
}
$config_names = array(
'local' => "local.php",
'global' => "global.php",
'file' => "file.php"
);
2015-01-09 15:33:25 +00:00
$configFile = $config_path .'autoload/' . $config_names[$configName];
unset($config_path);
unset($configName);
2015-01-09 15:33:25 +00:00
$config = new \Zend\Config\Config(include $configFile);
return $config;
}
}