public function getConfigList() { if (empty(self::$db_config_list)) { self::$db_config_list = Config::get("db", self::DB_CONFIG_FILE); } return self::$db_config_list; }
private function __construct() { if (isset($_GET['debug']) && $_GET['debug'] && Config::get("debug")) { $this->open_debug = true; } $this->start_time = microtime(1); $this->content = []; }
public static function factory() { // 获取缓存配置 $config = Config::get("cache", "cache"); $type = $config['type']; $cache_config = $config["{$type}"]['config']; // 根据配置实例化对应缓存类 if ($type == "redis") { $cache = new RedisCache($cache_config); } else { if ($cache_config['type'] == "memcache") { $cache = new MemCache($cache_config); } } return $cache; }
/** * 根据 uri 获取 controller && action * @param string $value [description] * @return [type] [description] */ public function getRouteMapping($base_uri = '') { $routes = Config::get(self::ROUTE_CONF, self::ROUTE_FILE); // TODO Add Route Cache foreach ($routes as $controller_name => $action_mappings) { foreach ($action_mappings as $action_name => $uri_patterns) { foreach ((array) $uri_patterns as $uri_pattern) { $pattern = '/^' . str_replace('/', '\\/', $uri_pattern) . '/'; preg_match($pattern, $base_uri, $matches); if (!$matches) { continue; } $this->setMatches($matches); return ["controller" => $controller_name, "action" => $action_name]; } } } return []; }
/** * 获取所有用到的拦截器 * @param [type] $controller_name [description] * @param [type] $action_name [description] * @return [type] [description] */ private function getActionInterceptors($controller_name, $action_name) { $list_all = Config::get("interceptor", "interceptor"); // 合并拦截器 if (isset($list_all["global"])) { $used_list = $list_all["global"]; } else { $used_list = array(); } if (isset($list_all["{$controller_name}"])) { $used_list = array_merge($used_list, $list_all["{$controller_name}"]); } $action_key = "{$controller_name}@{$action_name}"; if (isset($list_all[$action_key])) { $used_list = array_merge($used_list, $list_all[$action_key]); } // 过滤空元素 $used_list = array_filter($used_list); // 获取所有要执行的拦截器 $formated_list = array(); foreach ($used_list as $key => $value) { // 去除排除掉的过滤器 if (strpos($value, "!") !== 0 && !in_array($value, $formated_list)) { $formated_list[] = $value; continue; } $ignored = substr($value, 1); if (in_array($ignored, $formated_list)) { $ignored_key = array_search($ignored, $formated_list); unset($formated_list[$ignored_key]); } } return array_values($formated_list); }