diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c41ce9d6..8125a8062 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Fixed - Fixed model creation failure in webtools due to wrong variable mutation [#1415](https://github.com/phalcon/phalcon-devtools/issues/1415) +- Fixed config path detection to platform independent [#1426](https://github.com/phalcon/phalcon-devtools/issues/1426) ## Changed diff --git a/src/Builder/Path.php b/src/Builder/Path.php index acca94682..d79d8a2bd 100644 --- a/src/Builder/Path.php +++ b/src/Builder/Path.php @@ -43,34 +43,32 @@ public function getConfig($type = null): Config $type = isset($types[$type]) ? $type : 'ini'; foreach (['app/config/', 'config/', 'apps/config/', 'apps/frontend/config/'] as $configPath) { - if ('ini' == $type && file_exists($this->rootPath . $configPath . 'config.ini')) { + if ('ini' === $type && file_exists($this->rootPath . $configPath . 'config.ini')) { return new ConfigIni($this->rootPath . $configPath . 'config.ini'); - } else { - if (file_exists($this->rootPath . $configPath. 'config.php')) { - $config = include($this->rootPath . $configPath . 'config.php'); - if (is_array($config)) { - $config = new Config($config); - } - - return $config; + } + if (file_exists($this->rootPath . $configPath. 'config.php')) { + $config = include($this->rootPath . $configPath . 'config.php'); + if (is_array($config)) { + $config = new Config($config); } + + return $config; } } $directory = new RecursiveDirectoryIterator('.'); $iterator = new RecursiveIteratorIterator($directory); foreach ($iterator as $f) { - if (preg_match('/\/config\.php$/i', $f->getPathName())) { + if (false !== strpos($f->getPathName(), 'config.php')) { $config = include $f->getPathName(); if (is_array($config)) { $config = new Config($config); } return $config; - } else { - if (preg_match('/config\.ini$/i', $f->getPathName())) { - return new ConfigIni($f->getPathName()); - } + } + if (false !== strpos($f->getPathName(), 'config.ini')) { + return new ConfigIni($f->getPathName()); } }