本文整理匯總了PHP中Cml\Config::load方法的典型用法代碼示例。如果您正苦於以下問題:PHP Config::load方法的具體用法?PHP Config::load怎麽用?PHP Config::load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cml\Config
的用法示例。
在下文中一共展示了Config::load方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: parse
/**
* 從注釋解析生成文檔
*
*/
public static function parse()
{
$result = [];
$config = Config::load('api', Cml::getApplicationDir('app_controller_path') ? true : false);
foreach ($config['version'] as $version => $apiList) {
isset($result[$version]) || ($result[$version] = []);
foreach ($apiList as $model => $api) {
$pos = strrpos($api, '\\');
$controller = substr($api, 0, $pos);
$action = substr($api, $pos + 1);
if (class_exists($controller) === false) {
continue;
}
$annotationParams = self::getAnnotationParams($controller, $action);
empty($annotationParams) || ($result[$version][$model] = $annotationParams);
}
}
foreach ($result as $key => $val) {
if (count($val) < 1) {
unset($result[$key]);
}
}
$systemCode = Cml::requireFile(__DIR__ . DIRECTORY_SEPARATOR . 'resource' . DIRECTORY_SEPARATOR . 'code.php');
Cml::requireFile(__DIR__ . DIRECTORY_SEPARATOR . 'resource' . DIRECTORY_SEPARATOR . 'doc.html', ['config' => $config, 'result' => $result, 'systemCode' => $systemCode]);
}
示例2: parse
/**
* 從注釋解析生成文檔
*
*/
public static function parse()
{
$result = array();
$config = Config::load('api', false);
foreach ($config['version'] as $version => $apiList) {
isset($result[$version]) || ($result[$version] = array());
foreach ($apiList as $model => $api) {
$pos = strrpos($api, '\\');
$controller = substr($api, 0, $pos);
$action = substr($api, $pos + 1);
$reflection = new \ReflectionClass($controller);
$res = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
foreach ($res as $method) {
if ($method->name == $action) {
$annotation = $method->getDocComment();
if (strpos($annotation, '@doc') !== false) {
$result[$version][$model] = array();
//$result[$version][$model]['all'] = $annotation;
//描述
preg_match('/@desc([^\\n]+)/', $annotation, $desc);
$result[$version][$model]['desc'] = isset($desc[1]) ? $desc[1] : '';
//參數
preg_match_all('/@param([^\\n]+)/', $annotation, $params);
foreach ($params[1] as $key => $val) {
$tmp = explode(' ', preg_replace('/\\s(\\s+)/', ' ', trim($val)));
isset($tmp[3]) || ($tmp[3] = 'N');
$tmp[1] = substr($tmp[1], 1);
$result[$version][$model]['params'][] = $tmp;
}
//請求示例
preg_match('/@req(.+?)(\\*\\s*?@|\\*\\/)/s', $annotation, $reqEg);
$result[$version][$model]['req'] = isset($reqEg[1]) ? $reqEg[1] : '';
//請求成功示例
preg_match('/@success(.+?)(\\*\\s*?@|\\*\\/)/s', $annotation, $success);
$result[$version][$model]['success'] = isset($success[1]) ? $success[1] : '';
//請求失敗示例
preg_match('/@error(.+?)(\\*\\s*?@|\\*\\/)/s', $annotation, $error);
$result[$version][$model]['error'] = isset($error[1]) ? $error[1] : '';
}
}
}
}
}
$systemCode = (require __DIR__ . DIRECTORY_SEPARATOR . 'resource' . DIRECTORY_SEPARATOR . 'code.php');
require __DIR__ . DIRECTORY_SEPARATOR . 'resource' . DIRECTORY_SEPARATOR . 'doc.html';
}