Eva\EvaEngine\Engine::diConfig PHP Method

diConfig() public method

public diConfig ( )
    public function diConfig()
    {
        $di = $this->getDI();
        $cachePrefix = $this->getAppName();
        $cacheFile = $this->getConfigPath() . "/_cache.{$cachePrefix}.config.php";
        if ($cache = $this->readCache($cacheFile)) {
            return new Config($cache);
        }
        $config = new Config();
        //merge all loaded module configs
        $moduleManager = $di->getModuleManager();
        if (!$moduleManager || !($modules = $moduleManager->getModules())) {
            throw new Exception\RuntimeException(sprintf('Config need at least one module loaded'));
        }
        foreach ($modules as $moduleName => $module) {
            $moduleConfig = $moduleManager->getModuleConfig($moduleName);
            if ($moduleConfig instanceof Config) {
                $config->merge($moduleConfig);
            } else {
                $config->merge(new Config($moduleConfig));
            }
        }
        //merge config default
        $config->merge(new Config(include $this->getConfigPath() . "/config.default.php"));
        //merge config local
        if (false === file_exists($this->getConfigPath() . "/config.local.php")) {
            return $config;
        }
        $config->merge(new Config(include $this->getConfigPath() . "/config.local.php"));
        if (!$config->debug) {
            $this->writeCache($cacheFile, $config->toArray());
        }
        return $config;
    }