improved configuration loader, autoload is now compatible with windows

This commit is contained in:
Juan 2018-06-06 13:11:06 +02:00
parent e458b72748
commit b7a43145ca
6 changed files with 19 additions and 15 deletions

View File

@ -346,7 +346,7 @@ class Connection {
$i = 0;
$params = [];
foreach($paramsMap as $key => $value)
foreach ($paramsMap as $key => $value)
$params[$key] = $this->renderValue($value);
$replaceFunc = function($matches) use(&$params, &$i) {

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
php-vn-lib (2.1.4) stable; urgency=low
php-vn-lib (2.1.5) stable; urgency=low
* Initial Release.

View File

@ -85,14 +85,18 @@ class App {
*/
function getConfigFile() {
$configDir = _CONFIG_DIR .'/'. $this->name;
$customFile = "$configDir/config.my.php";
if (file_exists('config.php'))
return 'config.php';
else if (file_exists($customFile))
return $customFile;
else
return "$configDir/config.php";
$configFiles = [
"$configDir/config.my.php",
"$configDir/config.php",
"config.my.php"
];
foreach ($configFiles as $configFile)
if (file_exists($configFile))
return $configFile;
return 'config.php';
}
/**

View File

@ -33,7 +33,7 @@ namespace Vn\Lib {
setlocale(LC_ALL, $locale);
self::$localeSet = TRUE;
foreach(self::$paths as $path => $kk)
foreach (self::$paths as $path => $kk)
self::loadFile($path);
}
@ -93,7 +93,7 @@ namespace Vn\Lib {
* translation
*/
static function addTranslations($strings) {
foreach($strings as $string => &$translation)
foreach ($strings as $string => &$translation)
self::$strings[$string] = &$translation;
}
}

View File

@ -47,7 +47,7 @@ abstract class Method {
if (!isset($map))
return FALSE;
foreach($params as $param)
foreach ($params as $param)
if (!isset($map[$param])) {
return FALSE;
break;

View File

@ -6,7 +6,7 @@ $vnAutoloadReplace = function($matches) {
if (strlen($match) == 1)
return $match;
if ($match{0} == '\\')
return DIRECTORY_SEPARATOR. $match{1};
return '/'. $match{1};
return $match{0} .'-'. $match{1};
};
@ -18,7 +18,7 @@ spl_autoload_register(function($className) {
$classPath .= '.php';
if (isset($vnAutoloadMap))
foreach($vnAutoloadMap as $prefix => $location) {
foreach ($vnAutoloadMap as $prefix => $location) {
$prefixLen = strlen($prefix);
if (strncmp($classPath, $prefix, $prefixLen) == 0) {
@ -27,7 +27,7 @@ spl_autoload_register(function($className) {
}
}
if ($classPath{0} != DIRECTORY_SEPARATOR)
if ($classPath{0} != '/')
$classPath = stream_resolve_include_path($classPath);
if (file_exists($classPath))