Created function to abstract how to load config from a glob pattern

This commit is contained in:
Alejandro Celaya
2019-08-10 14:09:42 +02:00
parent 3520ab6b18
commit 02ca843944
7 changed files with 48 additions and 14 deletions

View File

@@ -3,6 +3,9 @@ declare(strict_types=1);
namespace Shlinkio\Shlink\Common;
use Zend\Config\Factory;
use Zend\Stdlib\Glob;
use function getenv;
use function json_decode as spl_json_decode;
use function json_last_error;
@@ -59,3 +62,11 @@ function json_decode(string $json, int $depth = 512, int $options = 0): array
return $data;
}
/**
* Loads configuration files which match provided glob pattern, and returns the merged result as array
*/
function loadConfigFromGlob(string $globPattern): array
{
return Factory::fromFiles(Glob::glob($globPattern, Glob::GLOB_BRACE));
}