Ajout helpers pour afficher la documentation du service, issue #0000339
This commit is contained in:
parent
21c381840b
commit
4c96305413
8
application/views/helpers/DocDescription.php
Normal file
8
application/views/helpers/DocDescription.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
class Zend_View_Helper_DocDescription extends Zend_View_Helper_Abstract
|
||||
{
|
||||
public function docDescription($method)
|
||||
{
|
||||
return $method['desc'];
|
||||
}
|
||||
}
|
41
application/views/helpers/DocMethod.php
Normal file
41
application/views/helpers/DocMethod.php
Normal file
@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
class Zend_View_Helper_DocMethod extends Zend_View_Helper_Abstract
|
||||
{
|
||||
public function docMethod($method)
|
||||
{
|
||||
$output = '';
|
||||
|
||||
$returnType = $method['return'];
|
||||
$methodName = $method['name'];
|
||||
|
||||
$cptParameters = 0;
|
||||
$parameters = '';
|
||||
foreach ($method['params'] as $param) {
|
||||
if ($param['optional']) {
|
||||
$parameters.= '[';
|
||||
}
|
||||
$parameters.= $param['type'];
|
||||
$parameters.= ' ';
|
||||
$parameters.= $param['name'];
|
||||
|
||||
if ($param['optional']) {
|
||||
if (isset($param['defaultValue'])) {
|
||||
$parameters.= ' = ';
|
||||
if (is_bool($param['defaultValue'])){
|
||||
$parameters.= ($param['defaultValue'] === false) ? 'false' : 'true' ;
|
||||
} else {
|
||||
$parameters.= $param['defaultValue'];
|
||||
}
|
||||
}
|
||||
$parameters.= ']';
|
||||
}
|
||||
$cptParameters++;
|
||||
if ($cptParameters < count($method['params'])){
|
||||
$parameters.= ', ';
|
||||
}
|
||||
}
|
||||
$output = $returnType . ' ' . $methodName . ' ( ' . $parameters . ' )';
|
||||
return $output;
|
||||
}
|
||||
}
|
54
application/views/helpers/DocParameter.php
Normal file
54
application/views/helpers/DocParameter.php
Normal file
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
class Zend_View_Helper_DocParameter extends Zend_View_Helper_Abstract
|
||||
{
|
||||
protected $serviceTypes;
|
||||
|
||||
public function docParameter($params, $serviceTypes)
|
||||
{
|
||||
$this->serviceTypes = $serviceTypes;
|
||||
$output = '';
|
||||
if (count($params)>0) {
|
||||
$output.= '<ul>';
|
||||
foreach ($params as $param) {
|
||||
$output.= $this->formatParam($param);
|
||||
}
|
||||
$output.= '</ul>';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
private function parseType($type)
|
||||
{
|
||||
$output = '';
|
||||
if (array_key_exists($type, $this->serviceTypes)) {
|
||||
$types = $this->serviceTypes[$type];
|
||||
$output.= '<ul>';
|
||||
foreach ($types as $param) {
|
||||
$output.= $this->formatParam($param);
|
||||
}
|
||||
$output.= '</ul>';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
private function formatParam($param)
|
||||
{
|
||||
$output = '';
|
||||
$output.= '<li>';
|
||||
$output.= $param['type'] . ' ' . $param['name'];
|
||||
if (isset($param['description']) && !empty($param['description'])) {
|
||||
$output.= ' : '.$param['description'];
|
||||
}
|
||||
if (!in_array($param['type'], array(
|
||||
'string', 'str',
|
||||
'boolean', 'bool',
|
||||
'interger', 'int',
|
||||
'float', 'double',
|
||||
'array', 'object', 'mixed'))) {
|
||||
$output.= $this->parseType($param['type']);
|
||||
}
|
||||
$output.= '</li>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
45
application/views/helpers/DocReturn.php
Normal file
45
application/views/helpers/DocReturn.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
class Zend_View_Helper_DocReturn extends Zend_View_Helper_Abstract
|
||||
{
|
||||
protected $serviceTypes;
|
||||
|
||||
public function docReturn($type, $serviceTypes)
|
||||
{
|
||||
$this->serviceTypes = $serviceTypes;
|
||||
return $this->parseType($type);
|
||||
}
|
||||
|
||||
private function parseType($type)
|
||||
{
|
||||
$output = '';
|
||||
if (array_key_exists($type, $this->serviceTypes)) {
|
||||
$types = $this->serviceTypes[$type];
|
||||
$output.= '<ul>';
|
||||
foreach ($types as $param) {
|
||||
$output.= $this->formatParam($param);
|
||||
}
|
||||
$output.= '</ul>';
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
private function formatParam($param){
|
||||
$output = '';
|
||||
$output.= '<li>';
|
||||
$output.= $param['type'] . ' ' . $param['name'];
|
||||
if (isset($param['description']) && !empty($param['description'])) {
|
||||
$output.= ' : '.$param['description'];
|
||||
}
|
||||
if (!in_array($param['type'], array(
|
||||
'string', 'str',
|
||||
'boolean', 'bool',
|
||||
'interger', 'int',
|
||||
'float', 'double',
|
||||
'array', 'object', 'mixed'))) {
|
||||
$output.= $this->parseType($param['type']);
|
||||
}
|
||||
$output.= '</li>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user