Skip to content

Commit

Permalink
online docs with tpl path
Browse files Browse the repository at this point in the history
  • Loading branch information
dogstarTest committed Nov 22, 2017
1 parent 8b181e0 commit ac3c42e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/app/Api/Examples/QrCode.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use PhalApi\Api;

/**
* 生成二维码 (免签名)
* 生成二维码
*/
class QrCode extends Api {

Expand Down
7 changes: 4 additions & 3 deletions vendor/phalapi/kernal/src/Helper/ApiDesc.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

class ApiDesc extends ApiOnline {

public function render() {
parent::render();
public function render($tplPath = NULL) {
parent::render($tplPath);

$service = \PhalApi\DI()->request->getService();
$namespace = \PhalApi\DI()->request->getNamespace();
Expand Down Expand Up @@ -112,6 +112,7 @@ public function render() {
$returns[$returnCommentArr[1]] = $returnCommentArr;
}

include dirname(__FILE__) . '/api_desc_tpl.php';
$tplPath = !empty($tplPath) ? $tplPath : dirname(__FILE__) . '/api_desc_tpl.php';
include $tplPath;
}
}
16 changes: 13 additions & 3 deletions vendor/phalapi/kernal/src/Helper/ApiList.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@

defined('D_S') || define('D_S', DIRECTORY_SEPARATOR);

/**
* ApiList - 在线接口列表文档 - 辅助类
*
* @package PhalApi\Helper
* @license http://www.phalapi.net/license GPL 协议
* @link http://www.phalapi.net/
* @author dogstar <chanzonghuang@gmail.com> 2017-11-22
*/

class ApiList extends ApiOnline {

public function render() {
parent::render();
public function render($tplPath = NULL) {
parent::render($tplPath);

$composerJson = file_get_contents(API_ROOT . D_S . 'composer.json');
$composerArr = json_decode($composerJson, TRUE);
Expand Down Expand Up @@ -146,7 +155,8 @@ public function render() {

$projectName = $this->projectName;

include dirname(__FILE__) . '/api_list_tpl.php';
$tplPath = !empty($tplPath) ? $tplPath : dirname(__FILE__) . '/api_list_tpl.php';
include $tplPath;
}
}

Expand Down
14 changes: 13 additions & 1 deletion vendor/phalapi/kernal/src/Helper/ApiOnline.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<?php
namespace PhalApi\Helper;

/**
* ApiOnline - 在线接口文档
*
* @package PhalApi\Helper
* @license http://www.phalapi.net/license GPL 协议
* @link http://www.phalapi.net/
* @author dogstar <chanzonghuang@gmail.com> 2017-11-22
*/

class ApiOnline {

protected $projectName;
Expand All @@ -9,7 +18,10 @@ public function __construct($projectName) {
$this->projectName = $projectName;
}

public function render() {
/**
* @param string $tplPath 模板绝对路径
*/
public function render($tplPath = NULL) {
header('Content-Type:text/html;charset=utf-8');
}
}

0 comments on commit ac3c42e

Please sign in to comment.