private function loadConfig(LoaderInterface $loader) { $files = $this->configManager->getFiles(); $config = []; // Load configs for all definitions. foreach ($this->configManager->getDefinitions() as $definition) { $type = $definition->getType(); $rawConfig = $this->loadFilesByType($loader, $files, $type); $config[$type] = []; if (false === empty($rawConfig)) { try { $config[$type] = $this->processor->processConfiguration($definition, $rawConfig); } catch (InvalidConfigurationException $ex) { throw ConfigException::validationError($ex->getMessage()); } } } // Check for configs without definitions. foreach ($this->configManager->getFiles() as $file) { if (false === $file->isLoaded()) { $name = $file->getType(); // Merge the array if it exists already. if (true === isset($config[$name])) { $config[$name] = array_merge_recursive($config[$name], $this->loadFile($loader, $file)); } else { $config[$name] = $this->loadFile($loader, $file); } } } return $config; }