2014-11-04 09:05:21 +00:00
|
|
|
<?php
|
|
|
|
namespace Westdc\Helpers;
|
|
|
|
|
|
|
|
class Config
|
|
|
|
{
|
2015-01-09 15:33:25 +00:00
|
|
|
|
2014-11-04 09:05:21 +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')
|
2014-11-04 09:05:21 +00:00
|
|
|
{
|
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"
|
2014-11-04 09:05:21 +00:00
|
|
|
);
|
2015-01-09 15:33:25 +00:00
|
|
|
|
|
|
|
$configFile = $config_path .'autoload/' . $config_names[$configName];
|
|
|
|
|
|
|
|
unset($config_path);
|
|
|
|
unset($configName);
|
2014-11-04 09:05:21 +00:00
|
|
|
|
2015-01-09 15:33:25 +00:00
|
|
|
$config = new \Zend\Config\Config(include $configFile);
|
|
|
|
|
2014-11-04 09:05:21 +00:00
|
|
|
return $config;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|