Max F 4 жил өмнө
parent
commit
ef78e84eff
2 өөрчлөгдсөн 31 нэмэгдсэн , 0 устгасан
  1. 15 0
      src/App.php
  2. 16 0
      src/Kernel.php

+ 15 - 0
src/App.php

@@ -210,4 +210,19 @@ class App
 		return $instances[$instance_name];
 	}
 
+
+	public static function getConfig($key=null)
+	{
+		$config = App::getData('config');
+		if (is_null($key)) {
+			return $config;
+		}
+
+		if (empty($config) || !isset($config[$key])) {
+			return null;
+		}
+
+		return $config[$key];
+	}
+
 }

+ 16 - 0
src/Kernel.php

@@ -90,6 +90,22 @@ class Kernel
 		if (! defined('ERROR_TEMPLATE')) {
 			//define('ERROR_TEMPLATE', "page_error.tpl.php");
 		}
+
+
+		// Load config files
+		$config_files = glob(APP_DIR . '/config/config-*.php');
+		$config = [];
+		foreach ($config_files as $config_file) {
+			$config_file_config = require($config_file);
+			$config_file_basename = basename($config_file);
+			$config_file_name = substr($config_file_basename, 7, -4);
+			$config[$config_file_name] = $config_file_config;
+			//print_r($config_file_name);
+		}
+		//echo "<pre>";print_r($config); exit;
+		App::setData('config', $config);
+
+
 	}