/** * 载入请求模板. * * 不存在模板文件或指定模板将返回一个空数组. * * @param string $module 模块名 * @param string $action 行为名 * @param string $templateName 模板名 * * @return array */ public static function loadTemplate($module, $action, $templateName) { if (!is_string($module) || !is_string($action) || !is_string($templateName)) { return array(); } if (($templates = self::loadCache($module, $action)) === false) { $filepath = Config::path("template/{$module}/") . $action . '.php'; if (!file_exists($filepath)) { return array(); } $templates = (require $filepath); if (!is_array($templates)) { return array(); } self::preserveCache($module, $action, $templates); } if (array_key_exists($templateName, $templates)) { return $templates[$templateName]; } return array(); }
/** * 根据格式将返回数据转为关联数组. * * @param mixed $data * * @return array|null */ private function parseReturnData($data) { $format = strtolower(Config::get('FORMAT')); switch ($format) { case 'json': return RV\Json::parse($data); break; case 'xml': return RV\Xml::parse($data); break; } }
/** * 根据格式将返回数据转为关联数组. * * @param mixed $data * * @return array|null */ private function parseReturnData($data) { $format = strtolower(Config::get("FORMAT")); switch ($format) { case "json": return RV\Json::parse($data); break; case "xml": return RV\Xml::parse($data); break; } }