19 private static function getLocalPaths($path): array
24 if (File::isFileExists($root .
'/bitrix/' . $path))
26 $paths[] = $root .
'/bitrix/' . $path;
29 if (File::isFileExists($root .
'/local/' . $path))
31 $paths[] = $root .
'local/' . $path;
37 private static function getConfigPaths(): array
39 if (!defined(
'CATALOG_CONTAINER_PATH'))
44 $configPaths = static::getLocalPaths(CATALOG_CONTAINER_PATH);
46 if (empty($configPaths))
54 private static function loadDependencies(
string $customPath =
null): array
58 $configPaths = static::getConfigPaths();
62 $configPaths[] = $customPath;
65 foreach ($configPaths as $configPath)
67 $current = include($configPath);
69 if (is_array($current))
71 $dependencies[] = $current;
76 'Config {%s} must return an array.', $current
81 return array_merge(...$dependencies);
88 if ($containerClass ===
null)
91 'Container dependency {%s} must be configured in the config file.',
97 return new $containerClass();
102 $dependencies = static::loadDependencies($customPath);
103 $container = static::buildContainer($dependencies);
105 foreach ($dependencies as $dependency => $entity)
107 $container->inject($dependency, $entity);