/
BaseLoadConfiguration.php
73 lines (57 loc) · 1.8 KB
/
BaseLoadConfiguration.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<?php
declare(strict_types=1);
/**
* This file is part of Laravel Zero.
*
* (c) Nuno Maduro <enunomaduro@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace LaravelZero\Framework\Bootstrap;
use ReflectionClass;
use Illuminate\Contracts\Foundation\Application as ApplicationContract;
use Illuminate\Foundation\Bootstrap\LoadConfiguration;
use Symfony\Component\Finder\Finder;
use function basename;
use function ksort;
/**
* @internal
*/
final class BaseLoadConfiguration extends LoadConfiguration
{
/**
* Get all of the configuration files for the application.
*/
protected function getConfigurationFiles(ApplicationContract $app): array
{
$files = [];
$configPath = $app->configPath();
$configFiles = Finder::create()
->files()
->name('*.php')
->in($configPath);
foreach ($configFiles as $file) {
$directory = $this->getNestedDirectory($file, $configPath);
$files[$directory.basename($file->getPathname(), '.php')] = $file->getPathname();
}
ksort($files, SORT_NATURAL);
return $files;
}
/**
* Get the base configuration files.
*
* @return array
*/
protected function getBaseConfiguration()
{
$config = [];
$reflector = new ReflectionClass($this);
$declaringClass = $reflector->getParentClass();
$dir = dirname($declaringClass->getFilename());
foreach (Finder::create()->files()->name('*.php')->in($dir.'/../../../../config') as $file) {
$config[basename($file->getRelativePathname(), '.php')] = require ($file->getPath() . '/' . $file->getFilename());
}
return $config;
}
}