webservice/application/views/helpers/DocParameter.php

59 lines
1.3 KiB
PHP
Raw Normal View History

<?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 = '';
2010-09-20 08:04:31 +00:00
$type = str_replace('[]', '', $type);
if (array_key_exists($type, $this->serviceTypes)) {
$types = $this->serviceTypes[$type];
$output.= '<ul>';
foreach ($types as $param) {
$output.= $this->formatParam($param);
}
$output.= '</ul>';
2010-09-20 08:04:31 +00:00
} else {
2010-10-20 12:29:41 +00:00
$output.= ' => <b>Type '.$type.' Inconnu</b>';
}
return $output;
}
private function formatParam($param)
{
$output = '';
$output.= '<li>';
2010-09-20 15:08:45 +00:00
$output.= '<i>' . $param['type'] . '</i>';
$output.= ' ';
$output.= $param['name'];
if (isset($param['description']) && !empty($param['description'])) {
$output.= ' : '.$param['description'];
}
if (!in_array($param['type'], array(
'string', 'str',
'boolean', 'bool',
2010-09-20 15:08:45 +00:00
'integer', 'int',
'float', 'double',
'array', 'object', 'mixed'))) {
$output.= $this->parseType($param['type']);
}
$output.= '</li>';
return $output;
}
}