57 lines
1.1 KiB
PHP
57 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Created by PhpStorm.
|
|
* User: Administrator
|
|
* Date: 2014/11/14
|
|
* Time: 11:34
|
|
*/
|
|
|
|
namespace Westdc\Service\ServiceAgent;
|
|
|
|
use Zend\Config\Config as Zend_Config;
|
|
use Zend\Config\Reader\Ini as ReaderIni;
|
|
|
|
class Config {
|
|
|
|
public function get($configName = "")
|
|
{
|
|
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 .= PATH_SEPARATOR;
|
|
}
|
|
|
|
$configFile = $config_path . $configName;
|
|
|
|
unset($config_path);
|
|
unset($configName);
|
|
|
|
if(!file_exists($configFile))
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
$configFileExt = pathinfo($configFile,PATHINFO_EXTENSION);
|
|
|
|
if($configFileExt == "php")
|
|
{
|
|
return new Zend_Config(include_once($configFile));
|
|
}
|
|
|
|
if($configFileExt == 'ini')
|
|
{
|
|
return new ReaderIni($configFile);
|
|
}
|
|
|
|
}
|
|
|
|
}
|