34 lines
762 B
PHP
34 lines
762 B
PHP
|
<?php
|
||
|
use Psr\Container\ContainerInterface;
|
||
|
use DI\ContainerBuilder;
|
||
|
|
||
|
/**
|
||
|
* @return ContainerInterface
|
||
|
* @throws Exception
|
||
|
*/
|
||
|
function buildContainer(): ContainerInterface
|
||
|
{
|
||
|
$builder = new ContainerBuilder();
|
||
|
$folders = [
|
||
|
'settings',
|
||
|
'setups'
|
||
|
];
|
||
|
foreach ($folders as $folder_name) {
|
||
|
$folder = implode(DIRECTORY_SEPARATOR, [
|
||
|
__DIR__,
|
||
|
$folder_name
|
||
|
]);
|
||
|
if (!file_exists($folder)) {
|
||
|
continue;
|
||
|
}
|
||
|
$files = new FilesystemIterator($folder);
|
||
|
foreach ($files as $file) {
|
||
|
if ($file->isDir()) {
|
||
|
continue;
|
||
|
}
|
||
|
$builder->addDefinitions($file->getRealPath());
|
||
|
}
|
||
|
}
|
||
|
return $builder->build();
|
||
|
}
|